Tap Forms – Organizer Database App for Mac, iPhone, and iPad › Forums › Tap Forms Template Exchange › Simple Prompter Message
- This topic has 7 replies, 4 voices, and was last updated 3 years, 10 months ago by Philip Jones.
-
AuthorPosts
-
November 4, 2020 at 1:51 AM #42490
Brecht DHeereParticipantHi,
Can someone give me a working example of the prompter function please?
I need the prompter for a simple thing: Delete a record and show me a prompter message: “Do you really want to delete the record?”. I’ve been searching hours and hours on the forum and trying a lot of things but it is to complicated and I don’t have more time to spend… Maybe someone has A TapForms Archive and is willing to share this so I can change it for my needs? It is for a custom Lay-out…
Thanks in advance!
BrechtNovember 4, 2020 at 9:33 AM #42491
Daniel LeuParticipantIn the script editor, there is the
Prompt for confirmation
template. That’s a good starting point. For your example, I just changed one string:function confirmExecution(question) { return new Promise(function(resolve, reject) { let prompter = Prompter.new(); prompter.cancelButtonTitle = 'No'; prompter.continueButtonTitle = 'Yes'; prompter.show(question, ((status) => { if (status == true) { resolve('Yes'); } else { reject(question + 'No'); } })); }); } async function myFunction() { try { await confirmExecution('Do you really want to delete the record?'); } catch (errorText) { // user clicked 'No' console.log('cancelled'); return; } // user clicked 'yes' // continue with function // main code here console.log('continue from yes'); } myFunction();
November 5, 2020 at 1:00 AM #42496
Brecht DHeereParticipantThanks Daniel!
I tried to set the scriptline for deleting the record in this place (see below) but the record is still there after I run the script until I refresh. Is this normal or am I doing something wrong?
Thanks,
Brecht…
async function myFunction() {try {
await confirmExecution(‘Do you really want to delete the record?’);
} catch (errorText) {
// user clicked ‘No’
console.log(‘cancelled’);
return;
}// user clicked ‘yes’
// continue with function
// main code here
form.deleteRecord(record);
console.log(‘continue from yes’);}
myFunction();
Attachments:
You must be logged in to view attached files.November 5, 2020 at 10:39 AM #42499
Brecht DHeereParticipantI think I found it. There maybe other (simpler) approaches but it works.
….
async function myFunction() {
try {
await confirmExecution(‘Record verwijderen?’);
} catch (errorText) {
// user clicked ‘No’
console.log(‘cancelled’);
return;
}
// user clicked ‘yes’
// continue with function
// main code herevar records = form.getRecords();
var field_id = ‘fld-7a3920ab535745e8a78213b49a8b13d9’;
var naam = record.getFieldValue(field_id);for (var index = 0, count = records.length; index < count; index++){
var aRecord = records[index];
var field_value = aRecord.getFieldValue(field_id);
if (field_value == naam) {
form.deleteRecord(aRecord);
}
}
form.saveAllChanges();
}
myFunction();November 5, 2020 at 10:49 AM #42501
Daniel LeuParticipantThe first version of the code was missing the
form.saveAllChanges();
. The second version of your code will delete all records that have the same naam. This might not be what you want.I would update the first version with
form.saveAllChanges();
. Sometimes the TapForms GUI doesn’t refresh upon changes. So the record might be deleted but you just don’t see it. Try clicking on ‘recalculate formulas’ to get the display updated. This should be fixed in the future (https://www.tapforms.com/forums/topic/advice-on-script-triggering/#post-42484).November 5, 2020 at 12:06 PM #42502
Brecht DHeereParticipantI tried the second version with the value of the creation date field but surprisingly, this doesn’t work.
So, I stick with the first version and do the ‘recalculate formulas’ click.November 5, 2020 at 7:13 PM #42504
Sam MoffattParticipant+1 to sometimes the GUI and the script engine have different views of the actual underlying state (generally the script is correct and GUI is out of sync).
December 28, 2020 at 8:37 AM #43003
Philip JonesParticipantIn my limited experience so far with Tap Forms, I must say that, although I love the software, the standout problem for me so far is, for lack of a better term, “Refresh Issues”.
A few things I notice consistently:
– GUI not showing what is then shown with a refresh (Mac)
– iPad OS version updating some fields but not others, fixed with a refresh
– Record list view requiring “clicks” to show current informationI have seen the allusion above to a fix. I also hope this comes soon and fixes the problems.
-
AuthorPosts
You must be logged in to reply to this topic.