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 - 106 through 120 (of 3,016 total)
  • Author
    Search Results
  • #52918
    Daniel Leu
    Participant

    1) Maybe it’s because you don’t use a default value. E.g., prompter.addParameter('Variety:', 'choice', 'popup', choices, choices[0])

    2) Instead of a form script, use a field script. They are automatically triggered when you use thisRecord.getFieldValue('fld-xxx'). You could call your form script form a field script as well after checking that your three fields are set.

    Cheers, Daniel

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

    #52913
    Mark Moran
    Participant

    Ended up creating a regular date field and then a script field that essentially set the new field with the Date Created field and ran the recalculation. Deleted the Date Created and Script field. Now I have the type field I want. 😀

    #52911
    Mark Moran
    Participant

    Hi all—

    I’ve got a Tap Forms JavaScript that works as follows:
    • From the Coins form, it reads three fields: Coin Type, Year, Mintmark.
    • If there’s a match, it looks up matching records in Coin Mintages (there can be multiple) and collects their Variety values.
    • It then presents those Variety options in a prompt so the user can pick one, and the choice is written back to the Variety field on Coins.

    Two issues I’m trying to solve:
    1. Prompt includes <unspecified>
    • The choice list always includes an extra <unspecified> entry even though I only push actual Variety strings.
    • What’s the correct way to prevent that entry from appearing? (e.g., do I need to filter out null/undefined/”” before calling the prompt function, or is there an option/flag in the Tap Forms prompt API that disables an empty choice?)
    2. Auto-run when 3 fields are completed
    • I’d like this to run automatically whenever Coin Type, Year, and Mintmark are all non-empty on a Coins record—so users don’t have to open the Scripts menu.
    • Is there a supported way to trigger a Form Script on field change/record save?
    • If not, would a Script field (or a calculated/auto script field) be the right pattern to re-evaluate and prompt as soon as those three fields are populated?

    ======

    // Coins → Form Script (current record only; clears Variety on <unspecified>)

    // === CONFIG ===
    const COINS_FORM_NAME = ‘Coins’;
    const MINTAGE_FORM_NAME = ‘Coin Mintage’;

    const COINS_FIELDS = {
    coinType: ‘fld-1231556e0f234de9b2d85f50225b8135’,
    year: ‘fld-4b84b047badd4d4cbb4a67ef6839522f’,
    mintMark: ‘fld-adb0be16f1a347dbbecc4ef562d779a7’,
    variety: ‘fld-2a73d81d137e4f718378819f5e4d54e0’
    };

    const MINTAGE_FIELDS = {
    coinType: ‘fld-fdf93db206d141bd956d8c9e7634f25e’,
    year: ‘fld-9579d7c74e88414daf27ccbc5d4e0346’,
    mintMark: ‘fld-8d72d0971ed34c2c9de6c03d240e9543’,
    variety: ‘fld-f76a6eb7ed0c4ae28b77fc6fdf055d53’
    };

    // === Script ===
    (function () {
    if (typeof record === ‘undefined’ || !record) {
    Utils.alertWithMessage(‘No Record’, ‘Run this from a Coins record.’);
    return;
    }

    function norm(v) { return (v === null || v === undefined) ? ” : String(v).trim(); }
    function eq(a, b) { return norm(a) === norm(b); }

    var coinType = norm(record.getFieldValue(COINS_FIELDS.coinType));
    var year = norm(record.getFieldValue(COINS_FIELDS.year));
    var mintMark = norm(record.getFieldValue(COINS_FIELDS.mintMark));

    if (!coinType || !year) {
    Utils.alertWithMessage(‘Missing Data’, ‘Current record needs Coin Type and Year.’);
    return;
    }

    var mintageForm = document.getFormNamed(MINTAGE_FORM_NAME);
    if (!mintageForm) {
    Utils.alertWithMessage(‘Form Not Found’, ‘Could not find form: ‘ + MINTAGE_FORM_NAME);
    return;
    }

    var mintageRecords = mintageForm.fetchRecords();
    if (!mintageRecords || mintageRecords.length === 0) {
    Utils.alertWithMessage(‘No Varieties’, ‘No records in Coin Mintage.’);
    return;
    }

    var choices = [];
    var seen = {};

    for (var i = 0; i < mintageRecords.length; i++) {
    var r = mintageRecords;
    var t = norm(r.getFieldValue(MINTAGE_FIELDS.coinType));
    var y = norm(r.getFieldValue(MINTAGE_FIELDS.year));
    var m = norm(r.getFieldValue(MINTAGE_FIELDS.mintMark));
    var v = norm(r.getFieldValue(MINTAGE_FIELDS.variety));
    if (!v) continue;

    if (eq(t, coinType) && eq(y, year) && eq(m, mintMark)) {
    if (!seen[v]) { seen[v] = true; choices.push(v); }
    }
    }

    if (choices.length === 0) {
    Utils.alertWithMessage(‘No Varieties’, ‘No matching Variety entries found in Coin Mintage.’);
    return;
    }

    choices.sort(function (a, b) { if (a < b) return -1; if (a > b) return 1; return 0; });

    var title = ‘Select Variety — ‘ + coinType + ‘ ‘ + year + (mintMark ? ‘ ‘ + mintMark : ”);
    var prompter = Prompter.new();
    prompter.cancelButtonTitle = ‘Skip’;
    prompter.continueButtonTitle = ‘Set Variety’;
    prompter.addParameter(‘Variety:’, ‘choice’, ‘popup’, choices)
    .show(title, function (continued) {
    if (!continued) return;

    // If user leaves the popup on <unspecified> (choice is falsy), clear the field.
    if (!choice) {
    record.setFieldValue(COINS_FIELDS.variety, ”);
    document.saveAllChanges();
    return;
    }

    record.setFieldValue(COINS_FIELDS.variety, String(choice));
    document.saveAllChanges();
    });
    })();

    #52893
    Chung-Bae Park
    Participant

    Danke, das bedeutet, das ich Tab Forms 5 (ohne Pro) noch für ca. 2 Jahre uneingeschränkt weiter nutzen kann?

    Wäre schön, wenn Sie bis dahin eine einmalige Kaufversion anbieten würden, denn ein Abo werde ich sicherlich nicht kaufen, aus Prinzip.

    Vielen Dank.

    Thanks. Does that mean I can continue to use Tab Forms 5 (without Pro) without restrictions for about two more years?

    It would be nice if you offered a one-time purchase version until then, because I certainly won’t buy a subscription, on principle.

    Thank you very much.

    #52884
    Brendan
    Keymaster

    Hi Chung-Bae,

    If the subscription lapses, Tap Forms Pro will go into a limited mode where you can see up to 10 records per form. You won’t be able to add new forms or add new records. But you can still export ALL your data so you can import it into another application if you choose.

    Thanks,

    Brendan

    #52883
    Chung-Bae Park
    Participant

    Hallo,

    leider wurde Tap Forms Pro ja nun ein Abo Modell.
    Dazu habe ich eine Frage:

    Was passiert, wenn ich ein Jahres-Abo abschließe, dieses aber nach 1 JAhr kündige, also das Abo nicht verlängere?

    Kann ich dann den letzten Software Zustand von Tap Form Pro uneingeschränkt weiter nutzen, oder ist eine weitere Nutzung dann nicht mehr möglich?

    Danke für Hinweise dazu.

    Gruß

    Hello,

    Unfortunately, Tap Forms Pro has now become a subscription model.
    I have a question about this:

    What happens if I sign up for an annual subscription but cancel it after one year, meaning I don’t renew the subscription?

    Can I then continue to use the last version of Tap Form Pro without restrictions, or will further use no longer be possible?

    Thanks for any feedback.

    Regards

    #52880
    Brendan
    Keymaster

    Peter,

    Your Result Type for your Total Script field is set to Text. Try setting it to Number and see if that solves your issue.

    Thanks,

    Brendan

    #52874
    Peter Riley
    Participant

    Thanks Daniel and yes, it’s the Inventory table, which should look like the attachment.

    My field script for the Total field is this: record.getTotalOfLinkedFieldForField('fld-ac6d9e3d03ae441994ff64b37ebba4f4', 'fld-b02673a0fe39401583e737a0876998e6');

    The interesting thing is that if I change the brew that currently has a total of 11 remaining bottles to a number less than 10 it works, so I guess you’re right in that the Total field is being interpreted as a string and therefore the search for a number less than 3 fails because it parses the first ‘1’ of ’11’ only. Using return parseInt(total) as follows doesn’t seem to make a difference (the console in the editor correctly displays 11):

    function return_total() {
    
    var total = record.getTotalOfLinkedFieldForField('fld-ac6d9e3d03ae441994ff64b37ebba4f4', 'fld-b02673a0fe39401583e737a0876998e6');
    return parseInt(total);
        }
    
    return_total();

    Thanks

    • This reply was modified 6 months, 3 weeks ago by Peter Riley.
    Attachments:
    You must be logged in to view attached files.
    #52869
    Daniel Leu
    Participant

    Is the table you’re revering to the Inventory table? Looks like you just discovered a but where the TFF file doesn’t contain the fields inside the table.

    In your script field, it might be that the result is interpreted as a string and not an number. You might want to try to use return parseInt(total); and set the return type accordingly. I don’t have the content of your script field so I’m just imagine what you might do.

    Good luck and cheers!

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

    Cheers, Daniel

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

    #52867
    Peter Riley
    Participant

    My home brew database has a record for each beer recipe and each record has a table field where I log each brew of that recipe. One of the table’s fields is Quantity (number of bottles produced) per brew, so there are usually several rows in the table. The main recipe record has a Total field that is a script field to sum the remaining bottles from the table Quantity field with this code:

    record.getTotalOfLinkedFieldForField(linkedFieldID, fieldID);

    to populate it, where linkedFieldID is the table ID and fieldID is the Quantity field.

    I have a search named ‘Brew Some More’ to filter the records where Quantity = 0. That works OK, but if I edit the search criterion to be ‘Quantity is less than or equal to 2’ I get beers with 11 bottles remaining, but not those with 4 or 8. I suspect I have a data type issue maybe?

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

    Hi Glen,

    So sorry for my delayed response.

    1. A Field Script can be written which will run automatically when the Company is selected from a Pick List. You could then use the Prompter feature in the script engine to fetch a list of addresses from the selected company and let the user select from a popup which address to select. It’s a bit involved in writing a script to do that though. Not sure how your JavaScript skills are. Look at the Prompter instructions in the online user manual:

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

    2. The Link to Form field popover view won’t filter the list of addresses based upon the selected Company Name. So that won’t work. Although you can type into the search field to find the company and it will filter the list. As long as the Company Street form also has a field that contains the company name.

    Thanks,

    Brendan

    #52857
    David Kramer
    Participant

    Question to Brendan Duttridge – On page 66 of the TFP manual shouldn’t this link to the Client Expenses form NOT the Client Call Log?

    GENERAL QUESTIONS

    (1) Field Types: What is the difference between TEXT field and NOTE fields. Can Notes fields be searched? What is the specifications in terms of number of characters for each?

    (2) Check Box. On my FM database I have Boolean fields. In FM they are either 1 or 0. Then in the layout I describe what the meanings are for 0/1. In TFP do I import them as numeric and can I then convert to a Checkmark. How? Or do I leave them as numeric and maybe a pick list will format numeric into correct items or checkmarks?
    Any ideas are welcome.

    THE FOLLOWING WAS A QUESTION I WAS GOING TO POST – BUT I THINK I HAVE A SOLUTION:

    3)on my FMDB I have 4-tables. Each one has a unique ID. I have exported them from FM as Merge files and massaged in Numbers. I have renamed the FM IDs as -rec_Form_Record_ID and imported as type=numeric.

    Three of the FM tables imported (mostly) correctly but one table reads only 2 records and stops (ignores 150+ records). In Numbers I deleted the first 10 records thinking there was something there causing problems but TFP still only reads 2 records.

    Then I had an idea. I opened the merge file in Excel. Saved it as CSV; changed the name. AND TFP imported ALL the records.
    There was a small problem in that TFP created additional records with field information out of order. However those were easily deleted.

    4) so I have imported my FM data. In each record there is rec_Form_Record_ID. I then redefined the child record id as Link-To the appropriate child record. Moved the link-to field onto the layout. I expected to see the child-records in the parent record. But I Do Not see the child records automatically. I do see the child records if I choose “Select existing linked records.” And manually link them. But not automatically based on stored ID values.
    Note: The import data prefaced the id fields with -rec_Form_Record_ID which I changed to Form_Record_ID once it was imported.

    5) In FM I used a starting value which is different for each table. Since I already have unique ID numbers how do I specify the starting ID number in TFP (starting from the last number ID used and then use an increment.

    6) after a lot of trial/error I was able to format field names and values (stroke/fill). But I could not get TFP to format a button I added to my form?

    7) I’m asking a favor. Can someone write a script for me that when runs opens a layout (1) within this form and or (2) opens a form in a different form. Once I have that as a template I’m sure I can figure out other buttons I need. Thank you.
    Forms:
    – Form1
    – Form2
    – Form3
    Layouts I created:
    – General
    – Instructions
    – Expenses

    Example: From the General layout the user may want to go to the Instructions [button] layout which is within the same form or may want to go to the Expenses [button] layout which is in a different Form.

    Thank you all.

    Glen B
    Participant

    Perhaps I am approaching this wrong.

    Simply put I have two Forms
    Company
    Order

    Company Form has multiple fields but only two that we are needing to work with for this problem
    Company Name
    Company Street

    On the Order Form there are two fields of interest
    Company
    Street

    On the Order Form Company is a Picklist from Company Form using Company Name field for the list

    The problem trying to be solved is that every Company may have multiple Street addresses so on the Order Form I would like to have the field Street be a Picklist based off of the Company selected in the Company field.

    My thoughts are:

    1. Can a script be triggered on the selection of the Company from the Picklist that then generates a list of Street values for that company and those are then populated into the Picklist for Street? Not sure what happens between records as different Companies or different Streets are needed.

    2. Or is there a relational link that can be done between the Street fields that utilizes a filter based on the Company selected.

    Any direction or solutions are appreciated (hopefully I have explained the problem clearly)

    regards,

    #52840
    Daniel Leu
    Participant

    Two things come to my mind:

    1. 1) Is client_first_name_and_email_address_details defined? Maybe the contact details link is missing. In this case I would use if (client_first_name_and_email_address_details == undefined) return; to skip the rest of your script. You might want to add a log message as well.
    2. 2) Did you just migrate to Tap Forms Pro? If yes, client_first_name_and_email_address_details is likely an array. So you might want to use just the first element with client_first_name_and_email_address_details[0].
    • This reply was modified 7 months, 1 week ago by Daniel Leu.

    Cheers, Daniel

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

    Victor Warner
    Participant

    I have a field script in Form which pulls in data from another Form (client_contact_details), which was working the last time I used it, but it is now producing an error:

    Email adress for invoice: TypeError: client_first_name_and_email_address_details.getFieldValue is not a function. (In 'client_first_name_and_email_address_details.getFieldValue(company_name_id)', 'client_first_name_and_email_address_details.getFieldValue' is undefined),line:(null)

    The script is now within a function, so I do not understand the error means. Any help in solving this would be greatly appreciated.

    The script:

    // Return values
    var Dear_Name = "Placeholder";
    var Email_to_send_invoice = "test@example.com";
    
    // Form ID
    var client_contact_details_id = 'fld-c53e48e48e3a40c7a5656ab92f39ecc9';
    var client_first_name_and_email_address_details = record.getFieldValue(client_contact_details_id)
    
    //Company details
    // company name
    var company_name_id = 'fld-a3300e3db044421598ae171c0a2d4834';
    var company_name = client_first_name_and_email_address_details.getFieldValue(company_name_id);
    
    console.log(company_name);
    
    if (company_name == null) {
    // first name of individual
        var first_name_id = 'fld-45599a4f0a6342d8973faed53dfbfed8';
        var first_name = client_first_name_and_email_address_details.getFieldValue(first_name_id);
    
        // Email address of individual
        var email_id = 'fld-8f9a928a7d554527b4127ef811136210';
        var email_individual = client_first_name_and_email_address_details.getFieldValue(email_id);
    
        Dear_Name = first_name;
        Email_to_send_invoice = email_individual;
    } else {
        // first name of company contact
        var first_name_company_contact_id = 'fld-24ee4dae33d941bf81e1667853a7a949';
        var first_name_company_contact = client_first_name_and_email_address_details.getFieldValue(first_name_company_contact_id);
    
        // email address of company contact
        var email_company_contact_id = 'fld-8cfa7613f04f4a8b82652bc27f3c05df';
        var email_company = client_first_name_and_email_address_details.getFieldValue(email_company_contact_id);
    
        Dear_Name = first_name_company_contact;
        Email_to_send_invoice = email_company;
    }
    
    console.log(Dear_Name + " " + Email_to_send_invoice);
    
    Email_to_send_invoice;
Viewing 15 results - 106 through 120 (of 3,016 total)