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,686 through 2,700 (of 3,049 total)
  • Author
    Search Results
  • #33526
    Stephen
    Participant

    Hi Brendan,

    Thanks for the response. Do I simply create a ‘script’ type field and enter the text as you’ve written?
    I have attempted exactly that with the result set as text and I do not see anything in the form.

    Have I skipped an obvious step?

    Many thanks, Stephen.

    #33524
    Brendan
    Keymaster

    Hi Stephen,

    If you add a Script field that returns record.deviceName;, that will display the name of the device that created the record.

    #33503

    In reply to: Grab data from url?

    Brendan
    Keymaster

    Hi Steve,

    You can access a Location field value from a Script field. The location field value will end up being a dictionary that you can reference like this:

    var location_field_id = 'fld....';
    var location_value = record.getFieldValue(location_field_id);
    var title = location_value['title'];
    var latitude = location_value['lat'];
    var longitude = location_value['lon'];
    
    // now you can do whatever you want with the values
    

    The script can only get the values from a Tap Forms field. It doesn’t have a way to get the geo location coordinates itself. So you just need to add a Location field to your form and then let Tap Forms get the location for you for that field. Or of course you can set it to whatever location you want. Now once you have the location value, then the script can get access to the data.

    Your friend will need Tap Forms because there are specific Tap Forms functions that he’ll need access to.

    #33500

    In reply to: Grab data from url?

    Steve Smith
    Participant

    Question: how does the ‘script field ‘ know the gps coordinates of the phone? I have a Location field in the form already, can the script field use that? Or can the script grab the gps coordinates itself from the phones gps?

    Also, I cannot write code, a friend will be writing this script for me. I will send him the script page link you posted above, and he has already looked at the NOAA api documents. He does not have TF, will that be an issue?

    #33494
    Brendan
    Keymaster

    Hello Giantonio,

    Yes. On a custom layout you can do that.

    Display the Layout inspector panel on the right.

    Then click on the “Button” button at the top-right of that screen.

    Then drag out a button. Give it a name and select on the inspector panel which Form script you’d like Tap Forms to execute when you click the button.

    You can also assign shortcut keys to Form Scripts to execute them quickly too.

    Thanks!

    Brendan

    #33493

    I’m using a table with one record only, to insert some statistics totals by some little form scripts.
    It’s very interesting access to other form.

    Is it possible make a button, or field, that execute one saved form script clicking over?

    #33492

    In reply to: Scripting Guide

    Brendan
    Keymaster

    Hi James,

    The Scripting topic in the in the manual can be found here:

    https://www.tapforms.com/help-mac/5.3/en/topic/scripts

    The JavaScript API topic is also there too.

    Is that what you were looking for?

    Thanks!

    Brendan

    #33491
    James Hayes
    Participant

    Is there any reference material as to what can be scripted along with what can be accessed?

    #33473
    Jose Barrera
    Participant

    trying to modify selected records on a form…

    #33463
    Brendan
    Keymaster

    Hi Gianantonio,

    There’s a snippet that does this for you.

    Just tap on the Child Records Loop snippet when you have a child field selected on the Script Edit window. If you’re using iOS, tap the snippet first, then Tap Forms will ask you which field you’d like to select. When you select the field, Tap Forms will generate the code for you that loops through the Table field records.

    Also you can double-click on a Table field or Link to Form field header and Tap Forms will write the code for you to get the child records.

    #33462

    Please, can you post a little example how looping a linked table?

    I don’t found field reference in a main record to identify linked table; instead I see fields in a linked table. But I don’t know how loop secondary records table.

    Thank,
    Gianantonio

    #33432
    Brendan
    Keymaster

    form.selectRecord(someRecord) is for telling Tap Forms to select a record. It’s useful when you use JavaScript to add a record to your form.

    For deleting a record, you need to get the record first before you can delete it.

    If you want to delete a single record in a loop, you have to first get the records from the form. Then loop through them, check the record to see if it’s the right one to delete, then call the function to delete it.

    var records = form.getRecords();
    var field_id = 'fld-....';
    for (var index = 0, count = records.length; index < count; index++){
        var aRecord = records[index];
        var field_value = aRecord.getFieldValue(field_id);
        if (field_value == 'some value') {
            form.deleteRecord(aRecord);
        }
    }
    
    form.saveAllChanges();

    Something like the above should work but it has to be modified for your own form of course.

    #33430

    In reply to: Grab data from url?

    Brendan
    Keymaster

    Hi Steve,

    Sure, you can do that using the Script feature. You need to know a bit of JavaScript, but there are functions to get data from a URL.

    See the docs for the JavaScript API:

    https://www.tapforms.com/help-mac/5.3/en/topic/javascript-api

    Also there’s a sample script on this page that shows you how to get JSON data from a URL:

    https://www.tapforms.com/help-mac/5.3/en/topic/scripts

    #33429

    Hy i se in javascript Api this:

    form.deleteRecord(someRecord);

    Can you telo me a little ex?
    There is also a form.selectRecord(someRecord)

    I dont understand what insert in someRecord

    In a script loop i want delete single record

    Thank

    #33382
    Brendan
    Keymaster

    Hi Steve,

    1. No, Tap Forms doesn’t have graphing ability directly in the app. You’ll have to export the data and import into Numbers or Excel or some other app that supports that.

    2. The Table field (and Link to Form fields) have a different structure than the main form your exporting. So that’s why they’re exported as separate CSV file.

    3. You can add fields on the fly, but they’ll apply to all the records in the form. When you edit a form, you’re simply editing the form’s template that will be displayed for every record within that form. So there’s no function for one record to have one set of fields and another record to have a different set of fields.

    4. This happens automatically when using a Link to Form or Table field obviously as you add additional records to the relationship. That’s because even in a Table field, the sub-fields apply to every sub-record within the Table field. Same for Link to Form fields.

    One solution of course is to just estimate how many bananas you will ever need and add as many fields that you need to handle the maximum case.

    Or if you used a One to Many Link to Form field on your parent “Activity” form, then you could add a Calculation or Script field in your child “Bananas” form that extracts certain information from the parent Activity form and displays it. That way you could just go right to the Bananas form and export all of that as a CSV file for analysis in Numbers or Excel. Each Banana record would contain that bit of information you extracted from the parent Activity record. Hope that makes sense.

    Thanks!

    Brendan

Viewing 15 results - 2,686 through 2,700 (of 3,049 total)