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 - 1 through 15 (of 2,972 total)
  • Author
    Search Results
  • #53322
    Shane
    Participant

    I did logically try that even before seeing it on your website and it didn’t do anything. However like you say, sometimes things are finicky as to when TFP updates so I’ll have another go at it.

    Also undocumented is how to spit out values of a sorted pick list array. It was intuitive and I figured it out, but in case anyone’s searching for it:

    var sortedList = pickList.sortedValues;
        for (var index = 0, count = sortedList.length; index < count; index++){
    		console.log(sortedList[index].value);
    	}
        document.saveAllChanges();
    }

    Adding a “.value” at the end of the indexed array will spit out the pick list value in typical javascript fashion.

    #53320
    Shane
    Participant

    Thanks for the input, I’ll explore those possibilities.

    I saw your website and see that you also see a lot of potential for some commercial applications with Tapforms. Employing this software in a commercial setting could potentially sell a lot of licenses to organizations. I think however, there is some room for improvement with respect to UI design in the layouts to make things more intuitive for a non-technical person. Even if power users can program these layouts for average users it would be beneficial.

    TLDR: In my case, I’m creating a productivity/ business organizer in Tapforms because I just couldn’t get anything else to work the way I wanted them to. To this, I want to be able to hand over the synchronized documents to my wife so she can help me with the business admin. She has to be able to intuitively navigate around the forms/ scripts to get things done.

    • This reply was modified 1 day, 9 hours ago by Shane.
    #53318
    Daniel Leu
    Participant

    You can add the script button {...} in the toolbar that displays all your favorited scripts. That’s what I do.

    I like to use my keyboard shortcuts and use my QuickLaunch script extensively (https://lab.danielleu.com/tapformspro/script-library/index.html?p=Quick-Launch). It provides a pop-up that allows you to select the document script you want to run.

    Another option is using a weblink field and linking this to the script url using the tfpro://... url scheme. You can get the script link in the script editor.

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

    Cheers, Daniel

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

    #53316
    Shane
    Participant

    Hey all, sorry to post so much but I’ve been spending a lot of time trying to explore the power of the Javascript API and I keep running into roadblocks while trying to create features for my project manager in Tapforms Pro. I just want to check my understanding of some of the JS functions.

    I know you can add values to a pick list by using the addValue method on a pick list object. I discovered that this will permanently add values to the pick list. I thought it would be cool idea to be able to dynamically create a pick list for a text field based on what’s happening in the form, but the addValue method is permanent. It would be cool to have a deleteValue which would allow for dynamically generated pick lists for a form/ document.

    Thanks.

    #53313
    Shane
    Participant

    I love the default layout as it’s quick, easy, and super clean. It’s very difficult to come up with something that clean looking by creating my own layout.

    The only disadvantage of the default layout is you can’t place script buttons on it (that I know of). It would be really useful to do have this functionality. Either something like a “button field” or a setting in the Script Field to control if the script field will execute the included script automatically or by button trigger in the default layout field. Some simple UI examples have been attached.

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

    In reply to: Totally lost on script

    Daniel Leu
    Participant

    Hi John,

    Please try following. Without having access to your document, I can’t verify the script, but hopefully, it works.

    function updateProperty(){
        // ————————————–
        // Parent form field IDs (Property)
        // ————————————–
        const PROP_PROPID = ‘fld-6716b8eda66d44339f6ba08f37334ea8’;
        const PROP_LASTNAME = ‘fld-89a63a63d13048e6847d747cc9a2f5df’;
        const LINK_TO_PROPERTY = ‘fld-e476bcbca1a9425ebe799373abc1ab73’; // inverse relationship link
    
        // ————————————–
        // Child form field IDs (Payment)
        // ————————————–
        const PMT_PROP = ‘fld-2a06b08909054396ae904b3fb2f4d04c’;
        const PMT_PAYEE = ‘fld-f050a0f16e1b41b8bf62ed96e567032f’;
    
        // ————————————–
        // Get the linked Property record
        // ————————————–
        var parentRecord = record.getFieldValue(LINK_TO_PROPERTY);
    
        if (parentRecord == null || parentRecord.length == 0    ) {
        // No linked property; exit safely
          console.log('No linked property', "#ff0000");
          return;
        }
    
        // parent record is an array, extract first element
        if (parentRecord.length = 1) {
            parentRecord = parentRecord[0];
        } else {
            console.log('Multiple linked properties', "#ff0000");
            return;
        }
    
        // ————————————–
        // Read values from the Property record
        // ————————————–
        var propId = parentRecord.getFieldValue(PROP_PROPID);
        var lastName = parentRecord.getFieldValue(PROP_LASTNAME);
    
        // ————————————–
        // Write values to the Payment fields
        // ————————————–
        record.setFieldValue(PMT_PROP, propId);
        record.setFieldValue(PMT_PAYEE, lastName);
    
        document.saveAllChanges();
        return;
    }
    
    updateProperty();
    
    

    Cheers, Daniel

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

    Brendan
    Keymaster

    So if you have the same join field in two child forms and the one in the main parent form, then you can simply add a couple Join link to form fields to your form and Tap Forms should handle joining them at the same time as long as all 3 field values match.

    Or do you mean compound join fields? If so you can simulate that with a Calculation or Script Field.

    • This reply was modified 4 days, 9 hours ago by Brendan.
    #53288

    In reply to: Totally lost on script

    john bluma
    Participant

    I am still lost on scripts on parent child relationships. I am trying to populate two fields
    on the payment(child)form with values from property (parent form).

    I don’t understand _ is the paarent record already in memory or di I need to
    do. read dto retrieve the data. Am I supposed to pass the variable names as varname of ‘varname’?

    I even tried ChatGPT to generate the following script andit errors out

    // ————————————–
    // Parent form field IDs (Property)
    // ————————————–
    const PROP_PROPID = ‘fld-6716b8eda66d44339f6ba08f37334ea8’;
    const PROP_LASTNAME = ‘fld-89a63a63d13048e6847d747cc9a2f5df’;
    const LINK_TO_PROPERTY = ‘fld-e476bcbca1a9425ebe799373abc1ab73’; // inverse relationship link

    // ————————————–
    // Child form field IDs (Payment)
    // ————————————–
    const PMT_PROP = ‘fld-2a06b08909054396ae904b3fb2f4d04c’;
    const PMT_PAYEE = ‘fld-f050a0f16e1b41b8bf62ed96e567032f’;

    // ————————————–
    // Get the linked Property record
    // ————————————–
    var parentRecord = record.getFieldValue(LINK_TO_PROPERTY);

    if (parentRecord == null) {
    // No linked property; exit safely
    return;
    }

    // ————————————–
    // Read values from the Property record
    // ————————————–
    var propId = parentRecord.getFieldValue(PROP_PROPID);
    var lastName = parentRecord.getFieldValue(PROP_LASTNAME);

    // ————————————–
    // Write values to the Payment fields
    // ————————————–
    record.setFieldValue(PMT_PROP, propId);
    record.setFieldValue(PMT_PAYEE, lastName);

    Can you make it clear to a dinosaur Cobol programmer?

    Are there any example forms that illustrate a working link between records
    and use scripts to manipjulate data?

    Thanks for any help you can give

    #53284
    Shane
    Participant

    Thanks for the reply.

    I did read that documentation, but isn’t that used to add a child record to a parent record? I was referring to changing the parent record to the child record.

    I guess if I wanted to copy template children to a new parent I could do it that way. I could use a script to essentially copy the child record info from a template parent record and recreate those children records under the new project name. However, I am still curious if you could use a script to change the parent record of a child record. :)

    • This reply was modified 5 days, 13 hours ago by Shane.
    Daniel Leu
    Participant

    Looks like you’re using TapForms5.

    Sometimes ChatGPT does a good job, sometimes it hallucinates and creates strange recommendations like inventing nonexisting API functions. In your script, you should add a document.saveAllChanges(); before you the return statement.

    Happy coding!

    Cheers, Daniel

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

    #53282
    Daniel Leu
    Participant

    I agree, the scripting feature is very powerful. Without it, I wouldn’t use TFP.

    You can add a linked record using var newRecord = record.addNewRecordToField(field_id); and to remove an existing record there’s record.removeRecordFromField(childRecord, field_id');. Here’s the link to the documentation https://www.tapforms.com/help-mac/pro/en/topic/javascript-api.

    Cheers, Daniel

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

    #53279
    Shane
    Participant

    Hey all, so far I’m excited about the power of scripting in TapForms and am trying to put it to good use.

    I’m trying to create a template system where I can copy/move placeholder records to a new parent record. Normally to assign a child record to parent record you would click the “Select and link existing records” object/ button which would bring up the possible parent records for reassignment (see screenshot). I’m wondering if this could be done through scripting.

    In this example I have a Clients parent form linked to a child Projects form.

    You can seem to access the parent record by doing the following (see second screenshot):

    function Reassign() {
    
        var clients = record.getFieldValue('fld-25ab19edf2014cc0952446ed09975851');
        console.log(clients);
    }
    
    Reassign();

    Console shows a record object:

    2025-11-23, 8:02:35 AM / Projects / Reassign
    [object CDRecord]

    So can we somehow code a different parent record for the child record somehow?

    Thanks.

    Attachments:
    You must be logged in to view attached files.
    Melanie Schaaf
    Participant

    Thanks for the tip Daniel!

    Unfortunately I wasn’t able to make your approach work, but I might not have implemented it correctly. I am a very beginner level script-writer.

    However, while I was looking for a solution in the forums last night, I found out that there is a custom GPT on ChatGPT and with its help I was able to fix the script and now it works on a 1:M relationship.

    The problem was that while a linked form in an M:M relationship returns an array of records and while in a 1:M relationship the form also returns an array on the “Many”side, it does not return on array on the inverse relationship side, as there is always only one record.

    The corrected script (with the aid of the Chat GPT assistant) now also extracts several fields with no problems:

    function Extraction_Collection_Data() {

    // get the linked parent record (ONE record in 1:M)
    var collection = record.getFieldValue(‘fld-9be76f6c90334bbbaa0e2c4dc3556358’);

    // destination field IDs in Embroidery Designs
    var entire_collection_on_file_id = ‘fld-ef5768afe70c46968999aae8f538aa65’;
    var collection_series_id = ‘fld-ee2bff7b5d8f4e7f80797e6ad144dc33’;
    var collection_series_photo_id = ‘fld-a1b6349df4124933a70abb6dd30728d5’;
    var collection_website_id = ‘fld-cb6dd1f0e77c4fbcba331141ecd66d5d’;

    // — CASE 1: no linked collection (collection == null)
    if (!collection) {

    record.setFieldValue(entire_collection_on_file_id, ”);
    record.setFieldValue(collection_series_id, ”);
    record.setFieldValue(collection_series_photo_id, ”);
    record.setFieldValue(collection_website_id, ”);

    return;
    }

    // — CASE 2: a single linked parent record exists

    var entire_collection_on_file = collection.getFieldValue(‘fld-c0f51c1134e84335aaf27c64fa0c0bf1’);
    var collection_series_name = collection.getFieldValue(‘fld-40cb304839354352875dcaefb9403a2f’);
    var collection_package_photo = collection.getFieldValue(‘fld-0ed3dcb5bf194e3996de901f86a390d5’);
    var collection_website = collection.getFieldValue(‘fld-40ed47e24443496b9e0bdfd9831ff570’);

    record.setFieldValue(entire_collection_on_file_id, entire_collection_on_file);
    record.setFieldValue(collection_series_id, collection_series_name);
    record.setFieldValue(collection_series_photo_id, collection_package_photo);
    record.setFieldValue(collection_website_id, collection_website);
    }

    Extraction_Collection_Data();

    I am very happy with this solution and can only recommend using the ChatGPT assistant for basic scripting help. For me it worked brilliantly!

    Shane
    Participant

    I remember doing this in MS Access where you could link / join more than one field from the parent to child table (form). In TFP it would open up a few very cool possibilities such as the ability to show/ edit/ create subsets of records.

    So for example, if you link a Project Field AND a Client Field to a child Tasks Form, it would auto-populate the Client and Project fields in the tasks form if you added a record.

    Similar in purpose, it would be cool to be able to use something like a “Link to” field to connect to a pre-created search. I know you can use Javascript to access Search records, but it would be easier for people to do it with a “Link to” field (or whatever it could be called). Clicking on the populated records would go to that set of (search result) records for editing. I feel adding records from this type of hypothetical field wouldn’t be possible because of the complexity of the user inputted search criteria.

    Thanks for reading.

    • This topic was modified 6 days, 8 hours ago by Shane.
    #53270
    Daniel Leu
    Participant

    The only thing I noticed is your return statement. Try to replace it with return done;.

    Since it’s the reverse relationship of a one-to-many, you could use a calculation field as well.

    Here’s a script for a single value, although it doesn’t contain any error checks: https://www.tapforms.com/forums/topic/totally-lost-on-script/#post-53221

    Cheers, Daniel

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

Viewing 15 results - 1 through 15 (of 2,972 total)