Do not save data for disable fields


Badge +3

I am having 2 radio buttons in a repeating section of the form.

The two options allows two panel (having many controls) in the repeating section to be disable and enable.

The problem is coming when the user write in a panel (having many controls in it)  than disable it by radio button, then user will have to fill the form for enable panel. i.e both the panels will have data in it. 

When I am submitting the task form, both the sections are being saved. I only wanted to save the section which was enable by radio button on the task the form. Or if there is another way to reset panel when the radio button disable a section. 

Please see image in the attachment for more clarify.


5 replies

Userlevel 5
Badge +12

Hello,

I would write some Javascript on the change event of the radio button to clear the fields when a change in selection is made.   I assume you are using classic on prem forms, correct?  Unfortunately JS is the only real way to solve this issue with this version of forms as there are no built in rules to clear the fields.

A code-less alternative would be to disable the selection of the radio button once any of the fields have text in it.  This can be done using the built in rules on Nintex forms and checking for isnullorempty.  This would force the user to manually  delete what they typed from one section before selection the radio button to fill in the other section.  I assume you only what ONE or the OTHER sections filled out, and if so, though tedious on the user, it will quickly train them what not to do.

Thanks

Mike

Badge +3

Thanks Mike for your suggestion. Yes I am using classic on prem forms. I have tried this using JavaScript. Since this is happening in the repeating section, the problem that I am facing is that my JavaScript is running only for the first row in the repeating section. Can I make this JavaScript run in all the rows?

Userlevel 5
Badge +14

Here is brief example of how to accomplish this. 

Form Setup


Besides the Repeating Section, I've created (3) Controls: 

216372_pastedImage_1.png

  1. Choice Control - OracleSelector:

    216373_pastedImage_2.png
  2. Single Line Text Control - ParkOption:

    216374_pastedImage_3.png

  3. Single Line Text Control - EntryOption: 

    216375_pastedImage_6.png

Once you have all of your controls into place, you'll need to generate a unique Formatting Rule for both 'types' of Controls. When I say 'Type' in this way, I mean, which one of the two Oracle Selections ("By Entry" or "By Park") you'd like the Control to be active for.

For Controls that should be ACTIVE when "By Park" has been selected, you'll use the following Rule: 

  • Picture Examples: 

    216377_pastedImage_8.png
    (From the Form Editor)


    216379_pastedImage_13.png
    (In the Rule's Formula Builder)


  • Actual Code:

For Controls that should be ACTIVE when "By Entry" has been selected, you'll use the following Rule: 

  • Picture Example: 
    216378_pastedImage_9.png
    (From the Form Editor)


    216380_pastedImage_14.png
    (In the Rule's Formula Builder)


  • Actual Code:

    • For Controls that should be ACTIVE when "By Park" has been selected:
      (function(formControlCall, oracleSelector, controlType) {
        var formControlID = formControlCall.split("'")[1] || "";
        var targetControl = sourceContext.find("[formcontrolid='" + formControlID + "'].nf-filler-control");
        var innerControl = NWF$(targetControl.find("[formcontrolid][id]")[0]);
        var returnValue = oracleSelector !== controlType;
       
        if ( returnValue && innerControl.val()) {
          innerControl.val("").trigger("blur");
        }

        return returnValue;
      }("{Control:Self}", OracleSelector, "By Park"))‍‍‍‍‍‍‍‍‍‍‍‍


    • For Controls that should be ACTIVE when "By Entry" has been selected:
      (function(formControlCall, oracleSelector, controlType) {
        var formControlID = formControlCall.split("'")[1] || "";
        var targetControl = sourceContext.find("[formcontrolid='" + formControlID + "'].nf-filler-control");
        var innerControl = NWF$(targetControl.find("[formcontrolid][id]")[0]);
        var returnValue = oracleSelector !== controlType;
       
        if ( returnValue && innerControl.val()) {
          innerControl.val("").trigger("blur");
        }

        return returnValue;
      }("{Control:Self}", OracleSelector, "By Entry"))‍‍‍‍‍‍‍‍‍‍‍‍

      (Please note that while you can copy and paste this code directly into the Formula of the Rule, you will need to replace the 'OracleSelector' placeholder at the very bottom of the code with the actual Named Control reference as shown in the pictures above)

Doing that should result in the following behavior

Default State: 

216381_pastedImage_37.png

When 'By Park' is selected: 
216382_pastedImage_38.png

When 'By Entry' is selected: 

216383_pastedImage_39.png

I hope that this helps you to solve your problem. 

Badge +3

That was awesome, I was looking for something like this, it helped me.

Userlevel 5
Badge +14

Excellent! That's great to hear! 

Reply