Tap Forms app icon half
Tap Forms Forum text image
Blue gradient background

Exchange tips and ideas with the Tap Forms community

Search Results for 'script'

Viewing 15 results - 2,191 through 2,205 (of 2,953 total)
  • Author
    Search Results
  • #38017

    In reply to: VLOOKUP Script

    Ron Kline
    Participant

    Have you ever tried this concept using script to access the other forms data rather than a link to form field?

    #38012

    In reply to: Scripting Time fields

    Martin Inchley
    Participant

    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.

    #38003
    Roy McKee
    Participant

    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.

    #37999

    In reply to: Database Corruption

    Sam Moffatt
    Participant

    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.

    #37995
    Sam Moffatt
    Participant

    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?

    #37992
    Roy McKee
    Participant

    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;

    #37981

    In reply to: Exporting to text file

    Brendan
    Keymaster

    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.

    #37978
    Sam Moffatt
    Participant

    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.

    #37977
    Eddy
    Participant

    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

    #37976
    Eddy
    Participant

    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

    #37964
    Sam Moffatt
    Participant

    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.
    #37963
    Martin Inchley
    Participant

    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.

    #37961
    Sam Moffatt
    Participant

    If you’re using a form script, then you’ll want to use something like Utils.alertWithMessage to display it if you aren’t sending it somewhere else, e.g.:

    Utils.alertWithMessage('Calculation Result', checked / records.length * 100);
    

    Or to put that as the full script using your field ID:

    var check_mark_id = 'fld-4cbc05636709431a8305cfb7739a9bc5';
    var records = form.getRecords();
    var checked = 0;
    for (record of records)
    {
    	checked += record.getFieldValue(check_mark_id);
    }
    
    let percentage = checked / records.length * 100;
    Utils.alertWithMessage('Calculation Result', percentage);
    percentage;
    

    You can paste that into the script editor without having to define a function and it will work. The default Tap Forms script sample includes a function because otherwise some of the flow control keywords like return don’t behave normally.

    Also in the script editor when you run it, it should give you the output on the left or any errors n on the right.

    Attachments:
    You must be logged in to view attached files.
    #37960
    Sam Moffatt
    Participant

    I used a file attachment field to get the file browser to prompt and select the file. Once you’ve done that, I think Tap Forms should have access to the file.

    So create a form somewhere with a file attachment field, add to it your AppleScript app and then you should be able to execute it.

    Also getting access to the latest beta should help you as well.

    #37955
    Roy McKee
    Participant

    Hi Sam
    Thanks for the script. I have created it as you say, replacing the check-mark-id and field ref, thus:

    function Script_Google_No_1_S() {

    // My Code
    var Google_No_1_id = ‘fld-4cbc05636709431a8305cfb7739a9bc5’;
    var records = form.getRecords();
    var checked = 0;
    for (record of records)
    {
    checked += record.getFieldValue(Google_No_1_id);
    }

    checked / records.length * 100

    Script_Google_No_1_S();

    but nothing happens. Have I done something wrong?

Viewing 15 results - 2,191 through 2,205 (of 2,953 total)