How to run/code script to operate in multiple Forms

Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch Forums Script Talk How to run/code script to operate in multiple Forms

Viewing 0 reply threads
  • Author
    Posts
  • September 15, 2026 at 7:08 AM #54527

    Victor Warner
    Participant

    In my Document there are a number of Forms, each of which has a field (all called “Import”). For some records in the Import field in each Form there is a letter “X”.

    This setup distinguishes records imported from another database. After some work on the imported records, I wish to delete the content of the fields which contain the “X” (not the record itself).

    The (Form) script I have to do this is below (one for each Form).

    However, I have to go into each Form and run the script.

    Is there a way:

    1. to run all the scripts at once (one after another)?, or
    2. to have a (Document) script which can go into each Form and delete the X in the Import field.

    The script:

    var importFieldID = 'fld-6514c959cf9d4b169d3696a6ba49a56b';
    [Changed for each Form]
    
    // Get all records in this Form
    var records = form.fetchRecords();
    
    var changed = 0;
    
    for (var i = 0; i < records.length; i++) {
    
        var rec = records;
    
        // Get the value of the Import field
        var value = rec.getFieldValue(importFieldID);
    
        // Only clear records where Import is exactly X
        if (value == 'X') {
            rec.setFieldValue(importFieldID, '');
            changed++;
        }
    }
    
    // Save the changes
    document.saveAllChanges();
    
    console.log('Records changed: ' + changed);
    

    Any help would be gratefully received.

Viewing 0 reply threads

You must be logged in to reply to this topic.