set a value for Classic Nintex form

  • 20 February 2020
  • 6 replies
  • 72 views

Badge +3

I used the following JS in my classic nintex form to set a value. But, it only works HrApproval value. Others value couldn’t set a value. Here is the sample JS code that i used.

6534i7B8D1DADAF0597CB.png


6 replies

Badge +8

Hi,

sorry I don´t understand what your code is trying to achieve.

You are always setting the same field (varStatus) to "Revision" - is that intended?

When you console.log() your variables from the top, what are their values?

 

 

Badge +3

@Tarf 

When ever user select one of the three values, the status field value should be 'Revision'. Inshort, when approvers declined the request, the status value would be 'Revision' instead of 'New'.

Badge +8

Okay understood, I´d suggest doing an or in your if then.

if(value1 == "No" || value2 == "No" || value3 == "No"){
NWF$("#" + field).val("Revision")
}

But anyway, when you console log your variables from the top, what does it say?

Badge +3

@Tarf ,

Still the same , doesn't have value when i run. Any solutions please ?

Badge +2

It appears to me that you have a JavaScript error in the first "else if" and in JavaScript as soon as there is an error in a script it tends to not behave predictably. 

 

I would suggest you simplify your "if" statment to just one of Variables that is not working to find the root cause. Once you get each Variable working within its own "if" statement then you will be able to put it all together. 

 

I just noticed this based on your naming convention it appears you are not referencing the correct field:

You ref:

var supervisorApproveValue = NWF$("#" + idsupervisorApproveValue).val();

Should it be this:

var supervisorApproveValue = NWF$("#" + idsupervisorApproveChoice).val();

 

Badge +8

When the console logs do not show any value, your issue might be when reading the values.

You mentioned setting the Status to Revision only works for hrApproverValue.

So I guess, the value for hrApproverValue is not empty in your logs?

 

I would make sure that my form fields have a javascript id, then publish the form and open it in chrome from the list (not in preview from forms designer). There you´ll be able to play with your values in the console (F12) until you manage to read the fields as needed. After that, update the forms javascript.

As mentioned by CarmScaffidi maybe you are not using the correct nintex forms js variables?

Reply