Hide a Link To Form Field based on checkbox

Tap Forms – Organizer Database App for Mac, iPhone, and iPad Forums Script Talk Hide a Link To Form Field based on checkbox

Viewing 1 reply thread
  • Author
    Posts
  • December 3, 2019 at 12:39 PM #38451

    rleathen
    Participant

    While I am not a javascript programmer, I can usually read through simple javascript code and understand what is happening. I am trying to write a simple script to show or hide a link to form field based on the value of a checkbox. Unfortunately it does not seem to be working even though it runs clean in the console log. Is there any quirky bugs in relation to scripts and link to form fields. I have included my simple script for reference. Thank you in advance for any assistance you can provide, it is greatly appreciated.

    function New_Script() {
    // get the check box id
    var the_check_box = ‘fld-25afad2179224c368867d5f688afe496’;
    // get value of check box – checked or not
    var checked = record.getFieldValue(the_check_box_id);
    // get id of the link to form field
    var bills_id = ‘fld-3af9c9d4356a4dbba70d1e09a6ef6db5’;
    // check if the check box is checked or not
    if (checked == true) {
    // true condition;
    console.log (“show bills”)
    bills_id.hideField = false;
    } else {
    // false condition;
    console.log (“hide bills”)
    bills_id.hideField = true;
    }
    }

    New_Script();

    December 3, 2019 at 1:29 PM #38452

    Daniel Leu
    Participant

    Update:

    hideField is a parameter to the field object and not to a fieldId:

    var field = form.getFieldWithId(fieldID);
    field.hideField = true;

    Original response:

    Two things come to mind looking at the script:

    1. you might need to run document.saveAllChanges(); at the end of the script
    2. sometimes changes done by a script are not directly visible in the GUI, you might need to refresh the record by pressing cmd-r or clicking on the ‘recalculate formulas’ button.
Viewing 1 reply thread

You must be logged in to reply to this topic.