Solved

Nintex Forms: How to disable or hide option in Choice control basing on à condition?

  • 30 September 2021
  • 6 replies
  • 790 views

I have a form with a Choice control. It has a number of choices (Refuser, Approuver, demande d'information), and I need to hide  or disabled the choice (demande d'information) based on some condition. In my case the condition is something like

Statut=="demande closed"

 

Thanks in advance guys

 

Regards

Moha

@thomas_xu 

icon

Best answer by DimaHijazi 30 September 2021, 14:53

View original

6 replies

Badge +5

@Momofiore 


Create a rule on the control "demande d'information" by following the below steps:



  1. Click on the control "demande d'information"

  2. In the top ribbon, click on Add Rule

  3. Choose a name for the rule

  4. Go to formula and choose equals() from the inline function

  5. for the parameters, 1st parameter choose Statut from Named Control and 2nd paratmer will be "demande closed"

  6. the formula should be like this: equals(Statut , "demande closed" )

  7. then choose the behavior Disable or Hide.



 


 

Hello @DimaHijazi
in fact my Choice control name is ValidationPro and it has 3 choices (Refuser, Approuver, demande d'information).
I'de like to hide the third choice (demande d'information) when
Statut=="demande closed"
Your Suggestion is to hide the hole validationPro basing on my condition.
Hope I explained more.
Any suggetion?
Thank you again
Badge +5

Hello @Momofiore,


you can do it by adding a JavaScript to your form.



  1. Give a class name to 'Statut' control .StatutClass

  2. Go to control properties of the drop down control.

  3. In the Advanced section, select Store Client ID in Java Script Variable as yes.

  4. This will open option to name the variable. Name the variable myOptions and click save.

  5. Now open form settings and open the Custom Java Script section.

  6. Here you can write your script and access the drop down using the ID that you have given in step 3.


NWF$('.StatutClass').change(function(){


if(NWF$('.StatutClass') = 'demande closed'){


NWF$("#"+myOptions).find("option[value='Option 1']").prop('disabled',true)}


});

Hello


I wonder If you can help me to do the step 1:
Give a class name to 'Statut' control .StatutClass ?


Here is a screenshut for Statut

Badge +5

It would be under formatting (see screenshot below). in addition to @DimaHijazi 's suggestion, you should put your on change function within document ready function. See example code below where I am assuming the status field is a text input control. You probably want to re-enable the choice value if the status text is something else as well. 


 



NWF$(document).ready(function() {   

    NWF$(".statusFieldClassName").change(function(){

        if(NWF$(".statusFieldClassName input")[0].value == 'status changed')

        {

            NWF$(".choiceClassName").find("option[value='Choice 1']").prop('disabled',true)

        }

       else

       {

               NWF$(".choiceClassName").find("option[value='Choice 1']").prop('disabled',false)

        }

    });

 });



 


 

Thanks you @DimaHijazi and @thomas_xu for the solution. I combined your solutions in order to get it. thank you!

Reply