Using code to replace rules

Forums Dynamic Forms for SharePoint Using code to replace rules


This topic contains 3 replies, has 2 voices, and was last updated by  Alexander Bautz 8 months ago.

  • Author
  • #20933

    Keith Hudson

    Alex, I’m experimenting with using custom JS functions instead of rules for our very complex forms. I’m wondering if I can do any of the following using already existing objects or functions rather than create my own functions:
    1. Change the selectedTab
    2. save an array of all the hidden fields on the form to a field on the list, and an array of all the required fields on the form to a field on the list (so I can use those arrays when the form opens on the next step in the process without having to preserve all the rules from the previous step).

  • #20938

    Alexander Bautz

    To change the tab you can use this snippet:


    The index is the tab index or the found in the Tab unique ID.

    To save an array of all hidden fields you can use this snippet:

    var arrOfHiddenFields = [];

    And to save an array of all required fields you can use this snippet:


    Please note that when using custom code to “drive the form logic” you may get some strange results when for example you toggle a tab and the internal functions in DFFS doesn’t know what fields are visible etc.


  • #20940

    Keith Hudson

    Thanks for the prompt reply, Alex. I’m trying to figure out how to ‘reconstitute’ the hidden fields the next time my form opens from the list column where I saved the array of hidden fields (my column is name ‘luHiddenFields’). So far, I’ve got this much:

    var arrHiddenFields = getFieldValue(“luHiddenFields”).split(“,”);
    for (var i=0; i < arrHiddenFields.length;i++){
    var fieldId = “dffs_” + arrHiddenFields[i];
    This successfully hides the fields. However, I think I also need to update the object in order to be able to capture the list of hidden fields when I save the current tab (in case more fields have been hidden). How would I do that? Or, should I just append the new hidden fields to my array of hidden fields stored in my luHiddenFields column?

  • #20942

    Alexander Bautz

    Are you combining this custom code with the use of rules to show or hide the fields? – if not, you can make it easier, but if you do you can just add these lines in your for-loop:[fieldId].hidden = true;[fieldId].hiddenBy.rule = true;


You must be logged in to reply to this topic.