How to disable a button in Nintex Forms using Scripts ?

  • 9 August 2019
  • 5 replies
  • 61 views

Basically, I have a Nintex Form, where based on the Status, the buttons at the bottom of the form changes. For example if the Status is "In Review" then only the Approve & reject Buttons are shown. The problem I am facing is - there is a field "Reviewer`s Notes" which must be filled before "Rejecting". So I need added validation where if Reviewers Notes is empty then Disable the Reject button. Once user has filled it up then the Reject button should be dynamically enabled. Hence I need the scripting solution and not the validation / Rules counterpart.

What I have tried is using

NWF$('.nf-save-button').removeAttr("disabled", "disabled");

But this is a class specifier and it is affecting all the Save buttons. I need to specifically disable the  Reject button. I have also tried to get the ID of the Reject button from the DOM use it like this. This also didnt work.

Check Button ID: ListForm_formFiller_FormView_ctl90_ed7c8a8f_dbac_436c_98ae_d32e3c9a3dc6 NWF$("#ListForm_formFiller_FormView_ctl90_ed7c8a8f_dbac_436c_98ae_d32e3c9a3dc6").prop('disabled',true); NWF$("#ListForm_formFiller_FormView_ctl90_ed7c8a8f_dbac_436c_98ae_d32e3c9a3dc6").removeAttr("disabled", "disabled");

 

Thanks for any help in advance. Also please let me know if I need to provide any more information.3887i17B9CCC44C0539F4.png3885i4ADA58319D5336DF.png

 


5 replies

Badge +17

Your code is touching all buttons because a save/submit button is the same regardless of how many times you replicate it.


 


With the new responsive designer for O365 you should be able to set a simple rule for this. Let me know if you are able to get this done.

You can assign CSS class to specific buttons you want to disable/enable. Select button on form, go to properties /more settings and under formatting section you can set assign CSS class.


Now in script you can use that class/es for button/s instead of generic classes ( nf-save-button etc. which are applied to all the similar type of buttons).


You can use this CSS way to manipulate all the controls very similar to any html form though it works only in classic form.


If any confusion with code let me know.


 


@bluezzz1 wrote:

Basically, I have a Nintex Form, where based on the Status, the buttons at the bottom of the form changes. For example if the Status is "In Review" then only the Approve & reject Buttons are shown. The problem I am facing is - there is a field "Reviewer`s Notes" which must be filled before "Rejecting". So I need added validation where if Reviewers Notes is empty then Disable the Reject button. Once user has filled walmart wire then the Reject button should be dynamically enabled. Hence I need the scripting solution and not the validation / Rules counterpart.


What I have tried is using


NWF$('.nf-save-button').removeAttr("disabled", "disabled");

But this is a class specifier and it is affecting all the Save buttons. I need to specifically disable the  Reject button. I have also tried to get the ID of the Reject button from the DOM use it like this. This also didnt work.


Check Button ID: ListForm_formFiller_FormView_ctl90_ed7c8a8f_dbac_436c_98ae_d32e3c9a3dc6 
NWF$("#ListForm_formFiller_FormView_ctl90_ed7c8a8f_dbac_436c_98ae_d32e3c9a3dc6").prop('disabled',true);
NWF$("#ListForm_formFiller_FormView_ctl90_ed7c8a8f_dbac_436c_98ae_d32e3c9a3dc6").removeAttr("disabled", "disabled");

 


Thanks for any help in advance. Also please let me know if I need to provide any more information.


 




I could get it done with O365 as eharris04 said.

Userlevel 4
Badge +10

Why do you need to do that with script and not rules ?


This could be done with some formatting rules.


 


We could imagine :


-Add One panel on your forms.


-This panel contains Approve&reject Buttons.


-This panel has a rule which hide if the status is not "In review"


-On the button reject, add a formatting rule who disable the button if : The Status = "In Review" AND if the control "Reviewer's Notes" is empty


 


-And the icing on the cake, in your pan, add a label with message "You must fill the Reviewer's note if you want to reject" and add a rule on it which : Hide if : Status = "In Review" AND if the control "Reviewer's Notes" is not empty


@nico wrote:

Why do you need to do that with script and not rules ?


This could be done with some formatting rules.


 


We could imagine :


-Add One panel on your forms.


-This panel contains Approve&reject Buttons.


-This panel has a rule which hide if the status is not "In review"


-On the button reject, add a formatting rule who disable the applinked button if : The Status = "In Review" AND if the control "Reviewer's Notes" is empty


 


-And the icing on the cake, in your pan, add a label with message "You must fill the Reviewer's note if you want to reject" and add a rule on it which : Hide if : Status = "In Review" AND if the control "Reviewer's Notes" is not empty




Thank you for this

Reply