Using code to replace rules

Forums Classic DFFS Using code to replace rules

Tagged: 

Viewing 3 reply threads
  • Author
    Posts
    • #20933
      Keith Hudson
      Participant

      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
      Keymaster

      Hi,
      To change the tab you can use this snippet:

      spjs.dffs.toggleSelectedTab(index);

      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 = [];
      jQuery.each(spjs.dffs.data.hiddenColTrackerObj,function(fin,o){
      	if(o.hidden){
      		arrOfHiddenFields.push(fin);
          }
      });
      setFieldValue("NameOfFieldToWriteTo",arrOfHiddenFilds.join(","));

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

      setFieldValue("NameOfFieldsToWriteTo",spjs.dffs.data.requiredFields);

      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.

      Alexander

    • #20940
      Keith Hudson
      Participant

      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];
      jQuery(fieldId).hide();
      }
      This successfully hides the fields. However, I think I also need to update the spjs.dffs.data.hiddenColTrackerObj 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
      Keymaster

      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:

      spjs.dffs.data.hiddenColTrackerOb[fieldId].hidden = true;
      spjs.dffs.data.hiddenColTrackerOb[fieldId].hiddenBy.rule = true;

      Alexander

Viewing 3 reply threads
  • You must be logged in to reply to this topic.