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 - 601 through 615 (of 3,053 total)
  • Author
    Search Results
  • alang
    Participant

    Hi Brendan,

    I used “Duplicate Document” from the “Database Documents” window to make a copy of a document for testing. When using the duplicate test document, I was confused when a script which changed field contents also changed contents of the field with the same name but in the original document I had made a copy of. I think what is going on is “Duplicate Document” made an exact copy of the script, which means the field IDs are the same in the original document and in the copied document. I am guessing that is why a script in the duplicated document is making changes to the original document.  If this is the case, I am wondering if this is expected behavior. Thank you.

    #49579
    Pinny Berlin
    Participant

    Ugh! Two seconds after posting this, I found the JavaScript API doc and it listed the function I needed – getFieldWithId().

    Sorry to waste everyone’s time. But I’m happy I discovered the API doc, and hopefully I can use it to avoid asking questions like this in the future. :)

    Thanks,

    Pinny

    #49578
    Pinny Berlin
    Participant

    Hello,

    I am trying to reference a specific record in my form by its ID. I was able to obtain the ID via this script:

    console.log(record.getId()); // returns ‘rec-6ca7e23ae2e44a2b94193cf0c8644ff6’

    Now I want to reference that record in my other scripts. For instance, that record has a field called location. I was hoping to reference it using the following code, but I get an error:

    aRecord = form.selectRecord("rec-6ca7e23ae2e44a2b94193cf0c8644ff6"); //record id of Current Location
    location = aRecord.getFieldValue('fld-5dc7a719a9ee49b4b0536be6fdffeb46');

    But it throws the error:

    TypeError: Argument does not match

    Objective-C Class, line:(null)

     

    I’m sure there’s a simple way to accomplish what I need (short of looping through each form record and checking the Id. Any help is appreciated!

    Thanks,

    Pinny

    #49557

    In reply to: Stepper

    Daniel Leu
    Participant

    On the iPhone, you can have Shortcuts as well. They use the shortcut app and work together with Siri. You can launch a scripts using them. I never used this as I barely us TF on my phone. Sam has a video where he shows how he uses Shortcuts. I hope this helps you get started: https://www.youtube.com/watch?v=B7oiWtRRuNY&t=559s&ab_channel=pasamio

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #49555

    In reply to: Stepper

    Glen Forister
    Participant

    Thanks for the syntax help.  Yep, that works.

    I notice an option to record a record shortcut.  On an iPhone, what kind of shortcut would work that would be quicker than going into the “Run a Script” menu?  The only thing I can think of is to go into another field and type “z”.  Kinda lame and it leaves something to clean up, but easier than the full menu to script run.

    Oops, in the manual, it looks like Menu Shortcut only works on the Mac, not the iPhone…

    • This reply was modified 2 years, 11 months ago by Glen Forister.
    #49553

    In reply to: Stepper

    Daniel Leu
    Participant

    First, you got to remove following two lines to fix the error you got:

    Reset_Stepper();
    
    }

    Would you like to reset the two values at the same time? If yes, then it can be done with one script, otherwise two separate scripts.

    Here is the template for two fields:

    function Reset_Stepper() {
    var field1_id = 'fld-xxx1';
    var field2_id = 'fld-xxx2';
    record.setFieldValue(field1_id, 0);
    record.setFieldValue(field2_id, 0);
    document.saveAllChanges();
    }
    
    Reset_Stepper();
    • This reply was modified 2 years, 11 months ago by Daniel Leu.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #49551

    In reply to: Stepper

    Glen Forister
    Participant

    Thanks for the confirmation.

    Another question.  I have two fields in this Form that has steppers.  I assume I have to have two scripts which are housed in the Scripts Tab next to the Fields tab.

    Attached is the error message.

     

    Attachments:
    You must be logged in to view attached files.
    #49549

    In reply to: Stepper

    Daniel Leu
    Participant

    Yes, record.setFieldValue() takes action only on the current record. Here is the link to the JavaScript API documentation: https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api

     

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #49548

    In reply to: Stepper

    Glen Forister
    Participant

    If I’m guessing right, the “record.setFieldValue” will activate and change only one record of the Form?

    I definitely don’t want to reset all the records, only the one I’m viewing.

    I tried to look at Scripting docs I have and couldn’t find

    record.setFieldValue  defined to verify this.

    I’m guessing setFieldValue is an action taken on a record.

    #49547
    Daniel Leu
    Participant

    Have a look at following response to a similar question: https://www.tapforms.com/forums/topic/how-to-increase-a-date-in-a-script/#post-49372

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #49544

    In reply to: Stepper

    Daniel Leu
    Participant

    Yes, this can be done with a form script. You just need to replace fld-xxx with the field if of your stepper field.

    function Reset_Stepper() {
    var stepper_id = 'fld-xxx';
    record.setFieldValue(stepper_id, 0);
    document.saveAllChanges();
    }
    
    Reset_Stepper();
    • This reply was modified 2 years, 11 months ago by Daniel Leu.
    • This reply was modified 2 years, 11 months ago by Daniel Leu.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #49543

    In reply to: Stepper

    Glen Forister
    Participant

    That method is not reliable and the Edit Field comment comes up.  It only works if I’m shaky enough to get rapid touches.

    Would a Scrip to it easier?  No, I don’t have the time to learn Script – I tried, but I can’t dedicate enough time to it.

     

    #49521
    Daniel Leu
    Participant

    One benefit of exposing the API I could see is to use JavaScript code to build a custom layout by setting the coordinates, height, width, font settings, and so on. That would be an interesting idea too.

    That’s something I’ve been thinking about. This would be a way to visually show the progress of actions (quoted, P.O. received, parts ordered, in production, shipped, invoiced, paid) like changing the color of certain graphic elements, like big arrows, squares, rectangles, etc.

    • This reply was modified 2 years, 11 months ago by Daniel Leu.
    • This reply was modified 2 years, 11 months ago by Brendan.
    • This reply was modified 2 years, 11 months ago by Brendan.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #49517
    Brendan
    Keymaster

    One benefit of exposing the API I could see is to use JavaScript code to build a custom layout by setting the coordinates, height, width, font settings, and so on. That would be an interesting idea too.

    #49506
    Pavel
    Participant

    Hi Brendan,
    I have this problem generally. Delete and replace field in layout is without effect.
    Maybe I make some stupid mistake. Simply script is here:

    function Fill_Match() {

    var ar_lv_r1_id = ‘fld-19384a3f4f1248ea82b16a9d4eee55e0’;
    var ar_lv_r2_id = ‘fld-68464406010642928be2d4722d5b73fa’;
    var ar_lv_r3_id = ‘fld-a09de8a68b6a4658bb030c677341a670’;
    var ar_hv_r1_id = ‘fld-15db9eb1f8be4797a7f787ee90d40d04’;
    var ar_hv_r2_id = ‘fld-47295e7cae1a46d6935848285ba24c82’;
    var ar_hv_r3_id = ‘fld-37dc77cbaf2941a285c76be51f14fa03’;

    record.setFieldValue(ar_lv_r2_id, ‘XXXX’);
    record.saveAllChanges;
    console.log(record.getFieldValue(ar_lv_r2_id));
    return;

    }

    Fill_Match();

Viewing 15 results - 601 through 615 (of 3,053 total)