Search Results for 'script'
Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Search › Search Results for 'script'
-
AuthorSearch Results
-
November 8, 2020 at 2:35 PM #42524
In reply to: Missing Field
Daniel Leu
ParticipantPatrice, just quoting Brendan from an earlier post:
Hi Patrice,
If you email me a backup of your document I can probably restore it.
or check the “Restore deleted items…” function in the File menu to see if it appears there.
Sorry for this trouble.
Thanks,
Brendan
Brendan can be reached at support@tapforms.com.
I have never encountered lost data as you describe it. Do you use any formulas or scripts that might have an unwanted side effect?
Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 5, 2020 at 7:13 PM #42504In reply to: Simple Prompter Message
Sam Moffatt
Participant+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).
November 5, 2020 at 10:49 AM #42501In reply to: Simple Prompter Message
Daniel Leu
ParticipantThe 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).Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 5, 2020 at 1:00 AM #42496In reply to: Simple Prompter Message
Brecht DHeere
ParticipantThanks 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 4, 2020 at 9:33 AM #42491In reply to: Simple Prompter Message
Daniel Leu
ParticipantIn the script editor, there is the
Prompt for confirmationtemplate. 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();Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricksNovember 2, 2020 at 2:26 PM #42484In reply to: Advice on script triggering
Brecht DHeere
ParticipantHi,
Why do I need to refresh before the record is deleted?
I’m using a field script on the Mac version.Thanks,
Brechtvar checkmark = record.getFieldValue (‘fld-cf7c770a0bb04dc7922e79b24467bbd1’);
if (checkmark) {
form.deleteRecord(record)
}
form.saveAllChanges();October 30, 2020 at 12:44 AM #42446In reply to: Basic information on scripting.
Sam Moffatt
ParticipantI had an attempt at making a much in depth look at the script field and also the first snippet which is the if statement. I’m not sure if it hits the mark or not but I figured I’d start by working through each of the snippets but then after I’d done a few test attempts decided to spend a lot more time on script fields in general and some of their quirks.
October 27, 2020 at 6:57 PM #42436In reply to: Students –Courses
Sam Moffatt
ParticipantImplementing that one is relatively straight forward, the child records loop does most of the heavy lifting for you. I need to go and time code the video but the intro to scripting video covers this (though perhaps I need to go take “simple” out of the title).
October 27, 2020 at 4:44 PM #42435In reply to: Copy data from field to new record
Brecht DHeere
ParticipantNew Feature
OK, it will come…October 27, 2020 at 9:22 AM #42432In reply to: Students –Courses
Brecht DHeere
ParticipantOK, number 2 seems a good solution but I can’t write such scripts :(
You don’t have a sample script that I can change for my form?October 27, 2020 at 8:14 AM #42431In reply to: Copy data from field to new record
Brecht DHeere
ParticipantYes, when I refresh the data is ok. Sometimes I have to go to field view to refresh.
It is not possible with a script to refresh that record? And is that a bug in TF?October 27, 2020 at 7:47 AM #42430In reply to: Copy data from field to new record
Sam Moffatt
ParticipantEvery so often TF doesn’t refresh the calc/script fields after a script execution, at the bottom of the record is a refresh to recalc that record and at the bottom of the list view is another one that will apply to all records in the form. If you see a calc/script field that looks wrong, just hit the refresh button and see if it fixes it up.
October 27, 2020 at 4:32 AM #42429In reply to: Email field autofill emailaddress
Brecht DHeere
Participant@Brendan: I figured it out already. New line in mailto: = %0A
The button thing is not working because I don’t know if it is possible to send email with a script. But I’m using the globe of the Website Address field in my new layout as a button and that works fine :)
October 26, 2020 at 10:49 PM #42426In reply to: Students –Courses
Sam Moffatt
Participant1. If you’re mapping multiple records together it’s the approach I recommend. You might end up wanting a fourth one to map courses to instances of the course that a student is enrolled in (sessions/semesters/offerings/something) but that might be going a bit too far.
2. You could put a script field inside your link form that joins all of the students into the link form or the course form. If you did an enrolments script field on the course that joined the students enrolled in it and set it as one of the list fields then it’ll show up when you’re selecting courses.
3. If you’re after a table of course to student list then the above script field should help there as well.
October 26, 2020 at 8:54 PM #42425In reply to: Copy data from field to new record
Sam Moffatt
ParticipantOf course! So this one is a little more indirect, you need to change the
let newRecord = form.addNewRecord();line to look at the parent of the current record.First step is to go to our Students form and double click on “Lessons” in the field list of script editor to copy the field ID of the “Lessons” link field, in the database I had, it generates this line
var lessons_id = 'fld-bd0476420e504001a5f20833fc66e7cb';.Now we jump back to our Lessons form and nuke the
let newRecordline, paste in thelessons_idline from above and double click on the “Students” in the field list of the script editor to get thestudents_idfield:var lessons_id = 'fld-bd0476420e504001a5f20833fc66e7cb'; var students_id = 'fld-a9af1b4e918b4cf2b9f7737de6476e40';Our next step is to get the parent Student record and then use it to add a new Lesson record to it:
var student = record.getFieldValue(students_id); var newRecord = student.addNewRecordToField(lessons_id);Putting it all together the updated script looks like this:
function copyField(fieldId, sourceRecord, destinationRecord) { destinationRecord.setFieldValue(fieldId, sourceRecord.getFieldValue(fieldId)); } function New_Lesson() { var lessons_id = 'fld-bd0476420e504001a5f20833fc66e7cb'; var students_id = 'fld-a9af1b4e918b4cf2b9f7737de6476e40'; var student = record.getFieldValue(students_id); var newRecord = student.addNewRecordToField(lessons_id); copyField('fld-531d3cf087fc4b63967e29b71d30ba53', record, newRecord); copyField('fld-a53801440fd543669e92f0fdf955fc85', record, newRecord); copyField('fld-4f95fc5da7eb4f6d891e66f2ee620ace', record, newRecord); form.saveAllChanges(); // Return id of new record return newRecord.getUrl(); } Utils.openUrl(New_Lesson()); -
AuthorSearch Results