Greetings,
Yes I was able to get things working but it did bring up a new question. Contained within my field of type ‘table’ I have a child field of type ‘checkmark’. The question is how do I respond to the click event (if this exists) so that I can run a script?
Currently the table is giving me a sum of one of the numeric child fields which is usually great. What I need to do is a SUMIF so that a given row in the table is added to the total only if its checkmark field is checked. I am okay if I need to write a script to do the math but I don’t know where to put the script so that it responds to the checkmark click event. I would rather automate this if I can and not be required to manually fire a form level script.
So I am playing around with the following script:
record.setRecordColor(‘#ff0000’);
Based upon given conditions I set the color I want and it works. The problem is when no conditions are met I don’t know how to reset the record back to the default color it is given when it was created. Any ideas how to do this? Also I am unsure how the text color is being set as this function seems to set the background color.
In the Script Editor, the linked form should show up on the left as an option. If you double click on the name of the form, it will insert the field ID for the Link to Form field. You can then use record.getFieldValue with that field ID and it will give you an array of records that are linked.
If you look in the snippets at the bottom, there is a “child records loop” snippet. If you select a field from the child record and click on this, it’ll insert a premade loop for you that will iterate over all of the child records and also pull out the selected record.
On the other side of a 1:M, record.getFieldValue can be used with a Link From Form field (enabled via “Show Inverse Relationship”) to retrieve the parent form.
Have you ever tried this concept using script to access the other forms data rather than a link to form field?
Please can I bump this, as the ability to call a correct time of arrival is crucial. Here’s a little extra info:
Context: I’m in a GMT timezone, Mac set to auto, all normal, currently winter so not British Summer Time.
Time Field: “Time of Arrival”. I want to extract the time from this field. It is currently set to 3.50 p.m.
If I use this script:
var time_of_arrival_id = 'fld-4957bec764cf480884d3c7f8cce5a271';
var thisTime = record.getFieldValue(time_of_arrival_id);
console.log(thisTime);
the console reports: Thu Jan 01 1970 14:50:30 GMT+0000 (GMT).
I.e it’s subtracted an hour from the time in the field.
But if I add the JS function .toLocaleTimeString() to the console.log line:
var time_of_arrival_id = 'fld-4957bec764cf480884d3c7f8cce5a271';
var thisTime = record.getFieldValue(time_of_arrival_id);
console.log(thisTime.toLocaleTimeString());
the console reports 15:50:30, which is correct.
I really need to know what’s going on, so that I can control it. Earlier in this thread, both Daniel and Brendan reported anomalies, but no one yet seems to have an explanation or a solution.
My mistake, Sam, I had inadvertently entered the wrong field ID. Sorry about that. I confirm the script is working fine. Thank you very much for your help, much appreciated.
Do you mind expanding on what might have happened with the sync incident? Can you also share how you have your sync setup? Were you using P2P sync? Were all devices added to each other? Was one device offline for an extended period of time?
For the Mac, do you have Time Machine set up and can you restore a copy of your document from a time before you noticed the sync issues to review it’s state?
1. A difference in record count is a relatively good thing, it means you might be able to pull changes out of each of the devices.
2. The attachments might have failed to sync properly and changes on one device have overwritten changes on another device. This is a part of the sync resolution system where the most recent change should win though it seems in this case that something didn’t sync properly.
3. This feels like you’ve not lost image attachments for those records but just find them in the wrong order?
To your questions:
1. *Is there a way to diff missing records?* I don’t know of an easy way to do this, I’ve been working on a set of Terminal tools that might do something like this (and get a more complete backup) however it isn’t user friendly.
2. *Is there a way to sort edited images?* If your image field is only intended to have one image, you might be able to write a script field to count the number of images that are in the field and find the records that need intervention. You might be able to use a script field to examine the photo field and see if there is a pattern to the filenames of the edited images. I’m not sure if you could use record.setFieldValue to re-order the images within the field but that would be the way forward.
On the second one I’d be hesitant to make any changes because if you do when it comes to resolution time, those changes could cause some more damages.
If you are comfortable with a less than polished experience and using the Terminal, I can upload one of the backup tools I have that tries to pull back old revisions of documents from a Tap Forms database. That might be able to find anything that you’re missing.
When you run the form script, what value does it show for you? The screenshot was from my form so is obviously going to be different for you and your form. Could you attach a screenshot of what you see? What makes it impossible?
Thanks Sam, the script now works although it provides an impossible result. There are currently 44 records (there will be hundreds when I have finished the DB). I am trying to work out the number of Google No 1’s out of the 44 records. There are 32 ticked, which is more like 75%. I see from your result that there were 33%, which was probably accurate at the time you did it. I can only assume something has changed i the script but cant see anything wrong.
This is how I have copied it:
var Google_No_1 = ‘fld-4cbc05636709431a8305cfb7739a9bc5’;
var records = form.getRecords();
var checked = 0;
for (record of records)
{
checked += record.getFieldValue(Google_No_1);
}
let percentage = checked / records.length * 100;
Utils.alertWithMessage(‘Calculation Result’, percentage);
percentage;
The Script engine doesn’t support reading or writing directly to files in the file system. It can only write to records.
You could export as a CSV file perhaps. I know that vCard files can contain multiple vCards within the same file. Maybe if the data was structured properly enough then you could achieve this.
It’s a little different for sure, it’s an attempt to bypass the MacOS restrictions though I guess it’s not working for you. In any case the next version will fix the record selection quirk so that means calling into Tap Forms will work for your use case. Apple keep locking things down which makes some of these more advanced scripting features a little harder to implement each year.
Howdy!
Actually I don’t know, id this is a feature request or if I just do not see the way, how to do it right now:
Our task is to export a text file out of a field of a record.
Concrete: I made a script field, that produces the complete code for a Vcard. So, until now, I copy the produced code/text to the clipboard, create a text file on the mac, copy the clipboard’s content into the text file, change the text file’s extention from “.txt” to “.vcf”. Than, finally(!), I can drag that VCARD to the Addressbook.
So, now, I am looking for a way to save the steps in the middle. It would be so great if a could (maybe triggered by a script) force tapforms to export the content of a record’s field to a file and chose the filenames ending/extension directly.
Any ideas?
Thanks in advance,
Eddy
Hi Folks!
I need to get access to the file names of stored pictures.
In the form “customers” every customer has a picture on/in his record. In a script i need to get the name of that file.
Using “.getFieldValue” does not help.
Any ideas?
Thanks in advance,
Eddy
Once I attached the app into the file attachment field, it successfully execute the app using my script. This wasn’t on the MAS version though, so it’s possible there’s some extra quirks there. Let me find that and see if I can get it to work there.
1. Open app
2. Ran script, got unable to run “null” error.

3. Added target app to file attachment field.
4. Ran script again, seemed to work.
It did ask to be able to control Tap Forms though, I did a manual Gatekeeper exception on the command line and that seemed to go away: spctl --add ~/Documents/argv.app/
The reason to add the files to the file attachment field is to bypass the sandbox security. Once an app on MacOS been granted access to a file outside of it’s sandbox, it’s allowed to access it later. That needs to happen through the system controlled file picker dialog which is why we use the file attachment pathway. You don’t need to run the script from there but for each new Mac you need to go through the same process to give Tap Forms access to the file.
Note: I’m on Mojave, it’s possible if you’re on Catalina they’ve tightened it up more.
Attachments:
You must be
logged in to view attached files.
1. Is there any info anywhere about getting a script to target a file in a file attachment field? The TapForms manual has a rather minimalist approach.
2. I’ve got the AppleScript app into the file, plus a PDF. Double-clicking the PDF runs Preview and brings up the file. Double-clicking the AppleScript app does nothing observable.