cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

Hello. I have a Nintex 2013 form that is using a choice dropdown to hide another form element based on a specific selection. The rule works perfectly if I manually select the option from the dropdown, but I'm trying to have the choice field update via jQuery (it is pulling the current user's office from Active Directory via a REST service call). This works great, but my Nintex rule doesn't fire when I update the field via JavaScript!

Here's the jQuery that updates the form field:

$('.dlo-dropdown select').val(officeValue); // this updates the form field and should fire the Nintex rule. the field updates, but the rule doesn't fire...

I have also tried triggering the on change event with jQuery, but no luck there either.

$('.dlo-dropdown select').val(officeValue).trigger('change'); // again this updates the form field and should fire the Nintex rule, but the rule doesn't fire...

Anyone had or found a work around for this issue?

Reply
50 Replies
Automation Master
Automation Master

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

You can use the following Javascript to force the rule to be executed (yourControlId is the variable name that you've populated in the settings of the control, Advanced section, "Client ID JavaScript variable name" field when "Store Client ID in JavaScript variable" is set to yes)

var yourControl = NWF$("#"+yourControlId);

NWF.FormFiller.Functions.ProcessOnChange(yourControl);

Hope this helps

Reply
Not applicable

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

That got it! Thanks so much for your help.

0 Kudos
Reply
Automation Master
Automation Master

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

You're welcome

I'm glad that I could help

0 Kudos
Reply
leif_frederikse
Nintex Newbie

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

Hi Caroline,

I have ALMOST that problem. My issue is, that when I initialize a drop-down using the .val syntax (like Baron) and the user then does not change the selection interactively (the default was just fine), then my field back in the Sharepoint list to which the control corresponds, is not given any value - it is just left blank. If on the hand the user changes the selection (in case the default was not what she wanted) the field in the list is updated just fine.

I tried the solution you suggested to Baron but it does not change anything. What other suggestions could I try?

Regards

Leif

Reply
Automation Master
Automation Master

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

Hi Leif,

To achieve this, you can use the following script :

var yourControl = NWF$("#"+yourControlId);

yourControl.val("yourNewValue");

yourControl.parent().find("input").val("yourNewValue");

NWF.FormFiller.Functions.ProcessOnChange(yourControl);

Hope this helps

Reply
leif_frederikse
Nintex Newbie

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

Hey Caroline,

That was exactly what I needed - actually the ProcessOnChange line was not even necessary - it was the yourControl.parent().find/"input").val("value") that did the trick.

Thanks a lot - that saved my day :-)

Regards

Leif

0 Kudos
Reply
Automation Master
Automation Master

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

Cool, I'm happy to help you

0 Kudos
Reply
milan_stojadino
Nintex Newbie

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

I have a similar issue.

SP Online -> Nintex Form -> SP LookUp Field (Drop Down)

The Value of the Drop Down on the Nintex Form can be changed with this Code:

NWF$("#" + jsID + " > option[title='Value1']").prop("selected", true);

But the new Value is not saved on the Form, this Field is left blank.

Even if I use NWF.FormFiller.Functions.ProcessOnChange.

The Drop Down looks like this in IE:

<select

title=""

class="nf-lookup nf-ignore-getvalue nf-associated-control"

id="ListForm_formFiller_FormView_ctl42_lookup0506c782_f780_4a66_b5e3_a71c2ba3c7a0_Lookup"

style="width: 100%;"

formcontrolid="d0f6f5a7-0f53-41c3-8254-92f06ddd5d98"

data-use-attribute-as-value="data-nfChoiceValue"

data-bind="css: cssClass, options: lookupItems, optionsValue: 'id', optionsText: 'title', attr:{ title: helpText, id: id, disabled: !enabled(), formcontrolid: formcontrolid }, optionsAfterRender: setOptionTitle, value: selectedItem, event: { change: dropdownlistChanged }">

<option title="Please select a value..." value="" data-nfChoiceValue="">Please select a value...</option>

<option title="Value1" value="2" data-nfChoiceValue="2;#Value1">Value1</option>

<option title="Value2" value="3" data-nfChoiceValue="3;#Value2">Value2</option>

<option title="Value3" value="1" data-nfChoiceValue="1;#Value3">Value3</option>

</select>

0 Kudos
Reply
Automation Master
Automation Master

Re: Nintex form rule doesn't fire when select dropdown is changed via JavaScript

Jump to solution

You can try with the following code :

var yourControl = NWF$("#"+yourControlId);

var value = yourControl.find("option[title='Value1']").attr("value");

yourControl.val(value);

yourControl.parent().find("input").val("Value1#--#" + value);

NWF$(NWF$(this).parent().find("input")[1]).val(value);

0 Kudos
Reply