Hide fields with script

Viewing 8 reply threads
  • Author
    Posts
  • July 9, 2020 at 7:17 AM #41234

    Jean-Pierre Hermans
    Participant

    Is it possible to hide different fields with a script? And if yes, can someone give an example because this is complete new for me.
    I have a checkbox and when it’s checked then some fields in that record needs to be hided.
    Thank you.

    July 9, 2020 at 9:35 AM #41235

    Daniel Leu
    Participant

    Yes, this can be done. Unfortunately, everytime you update your checkbox field, you have to click on Recalculate Formulas to get the update.

    Here is my field script:

    var hide_field_id = 'fld-xxx';
    var target_field_id = 'fld-xxx';
    
    var field = form.getFieldWithId(target_field_id);
    var status = '';
    
    if (record.getFieldValue(hide_field_id)){
    	field.hideField = true;
    	status = 'hiding field';
    } else {
    	field.hideField = false;
    	status = 'showing field';
    }
    
    document.saveAllChanges();
    
    status;
    July 9, 2020 at 9:49 AM #41240

    Daniel Leu
    Participant

    After thinking about it a bit more, I don’t think using hideField for your purpose is the intended purpose! So most likely, this will not work for you.

    July 9, 2020 at 9:55 AM #41241

    Jean-Pierre Hermans
    Participant

    What could then be a solution to hide fields when checkbox checked?

    July 10, 2020 at 9:15 AM #41246

    Daniel Leu
    Participant

    Why do you want to hide a field? It might be helpful to understand your intent.

    July 18, 2020 at 10:34 AM #41361

    T.L. Ford
    Participant

    Tap Forms needs a javascript call to refresh the form display (similar to the View | Refresh Records List menu item). This would also solve a script on a many-side not correctly refreshing the view on the one-side.

    Tried several ways (attached), but none are an acceptable solution.

    Attachments:
    You must be logged in to view attached files.
    July 18, 2020 at 11:27 AM #41367

    Daniel Leu
    Participant

    Tap Forms needs a javascript call to refresh the form display (similar to the View | Refresh Records List menu item).

    +1

    I’ve been asking for such a feature for a long time… Nice to see someone else wanting it as well :)

    July 18, 2020 at 4:14 PM #41372

    T.L. Ford
    Participant

    Main use case for a form.refresh(); function (one-side summary/many-side data). See attached video.

    You can get around the show/hide fields using the built-in section headers and the default form (although I did get a bug when it duplicated fields, but I think the form just wasn’t fully saved and it self-resolved).

    Attachments:
    You must be logged in to view attached files.
    July 19, 2020 at 6:58 AM #41379

    T.L. Ford
    Participant

    Didn’t realize the tff would rekey the objects on import and break js. Same 4 forms as a tapforms backup.

    Attachments:
    You must be logged in to view attached files.
Viewing 8 reply threads

You must be logged in to reply to this topic.