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

Dropdown value set by JS not saved to field

We have a requirement to set the value of a dropdown based on a user. We are using calculated field to get the userprofile and on load, we set the dropdown based on this calculated value.

Currently, we are able to select the entry by binding a function after NWF.FormFiller.Events.RegisterAfterReady - my codes are shown below.

ddlDepartment is the javascript variable for my dropdown

preparedByDepartment is a calculated field

NWF$("#" + ddlDepartment).change(function () {
                  SelectDropDown(ddlDepartment, NWF$("#" + preparedByDepartment).val())

     });

function SelectDropDown(dropdown, selection) {
    NWF$("#" + dropdown + " > option[title='" + selection + "']").prop("selected", true);

}

After execution, the correct option is selected, but on saving, it shows blank.

Appreciate any help.

PS - I've tried the solution here Set default value to lookup field stopped working after Nintex Forms 2013 latest update  but doesn't work for my case.

0 Kudos
Reply
3 Replies
Nintex Newbie

Re: Dropdown value set by JS not saved to field

Try trigger focusout for control or call ProcessOnChange after correct option is selected:

ctrl.trigger("focusout");

or

NWF.FormFiller.Functions.ProcessOnChange(ctrl);

Reply
Not applicable

Re: Dropdown value set by JS not saved to field

Didnt work

I managed to solve it following this thread Nintex form rule doesn't fire when select dropdown is changed via JavaScript

This solved my problem

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

0 Kudos
Reply
Nintex Newbie

Re: Dropdown value set by JS not saved to field

Use .change().

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

0 Kudos
Reply