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,506 through 2,520 (of 2,864 total)
  • Author
    Search Results
  • #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

    #33357
    Brendan
    Keymaster

    Hi Greg,

    There’s no function to search a parent form for any values contained in a related form.

    However, you can workaround this by using either a Script field or a Calculation field.

    On your form B, add a Calculation field. Edit the formula and choose a field from the list of fields that show up that are contained within the parent form A. Any field will do. Then you can add a Saved Search that checks to see if the value of the calculation field is empty or not.

    Hope that helps.

    Thanks,

    Brendan

    #33354
    Victor Warner
    Participant

    Brendan,

    Thank you very much! Problem solved.

    I will hide the script field (as you have suggested), but just to know for the future, will that script field always show a ‘1’ regardless of what is in the other fields?

    #33351
    Victor Warner
    Participant

    Brendan,

    Thank you for the explanation.

    I have tried to follow the approach you outlined. But it appears not to work: the script field and the Time Charge For fields are not updated.

    I created:

    1. Time spent Field = type: number
    2. Time spent to time charged for Field = type: script.
    3. Time charged for Field = type: number.

    The Time spent to time charged for Field only shows a “1” regardless of what I put in the Time spent Field and the Time charged for Field is not updated.

    Attached is the Form. Could you let me know where I have gone wrong?

    Attachments:
    You must be logged in to view attached files.
    #33344
    Brendan
    Keymaster

    Hi Victor,

    Yes. You can do this with a Script field.

    In a Script field when you use the record.getFieldValue(field_id) function, Tap Forms begins watching that field for any changes made to it. It executes the script if the value of that field changes.

    So by adding a Script field, you could have Tap Forms copy the value from your Time Spent field into your Time Charged field. Now normally a Script field will display its contents in your form, but recently I added a Hide field function to Tap Forms 5.3 which will let you hide any field. So you could have this hidden Script field that’s just watching what’s going on with your form and running automatically when fields the script is watching change.

    Thanks!

    Brendan

    #33309
    Brendan
    Keymaster

    Hi Victor,

    You would need to use a Script field instead of a Calculation field to be able to do something like that.

    Here’s a sample that might help:

    var first_name_id = "fld....";
    var last_name_id = "fld...";
    var middle_name_id = "fld...";
    var firstName = record.getFieldValue(first_name_id);
    var lastName = record.getFieldValue(last_name_id);
    var middleName = record.getFieldValue(middle_name_id);
    var fullName = "";
    if (middleName) {
       fullName = firstName + " " + middleName + " " + lastName;
    } else {
       fullName = firstName + " " + lastName;
    }
    
    var result = fullName.toUpperCase();
    result;
Viewing 15 results - 2,506 through 2,520 (of 2,864 total)