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 - 496 through 510 (of 2,951 total)
  • Author
    Search Results
  • #49601
    Daniel Leu
    Participant

    The result is stored in the variable d. So you can take this and store the values in their respective fields.

    record.setFieldValue(symbol_field_id, d["Global Quote"]["01. symbol"]);
    ...
    document.saveAllChanges();

    Most likely you want to create a new record where you save all these information so you can do some analysis over time.

    The JavaScript API documentation is here: 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

    Brendan
    Keymaster

    Hi Alan,

    The Duplicate Document function just takes a copy of the document as is, copies it, and assigns it a new, unique Document ID. That’s all it does. So all field IDs, record IDs, form IDs, and so on will all be identical.

    But a script should not make changes to a different document. It should still only operate on its own forms.

    Can you check the Document IDs on each document to see if they are in fact different?

    Thanks,

    Brendan

    alang
    Participant

    Don’t know if I should have rewrote my original post.  But looking at this further, I think “Duplicate Document” is referencing the same actual script object?  When I make a change to the script in the duplicate document, those edits appear in the script in the original document.

    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, 5 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, 5 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, 5 months ago by Daniel Leu.
    • This reply was modified 2 years, 5 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.

     

Viewing 15 results - 496 through 510 (of 2,951 total)