sdspecy
Design Dabbler

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

Does somebody has a clue why this code bellow doesn't work in Forms version 2.10 ? It used to work till recent upgrade
Error: "ko" is not defined
It's about passing a value to a lookup filed from an URL string.

NWF.FormFiller.Events.RegisterAfterReady(function () {
    setItemId();
 });function setItemId() {
    var itemId = fn-GetQueryString('LookupId');
    if (Number(itemId) > 0) {
        var ddItem = NWF$('#' + inputItem);
        var vm = ko.dataFor(ddItem[0]);
        vm.initialValue = itemId;
    }
}

It seems that if I start with a (document).ready event for the same purpose (of course the code is a bit different then as shown bellow), I have a hard time running the rest of the code with some AJAX / REST calls etc,; in this case these are fired as soon as  lookup filed (another one) is selected, instead after the submit function.

NWF$(document).ready(function () {
    setItemId();
 });
function setItemId() {
    var item_Id = getParameterByName('LookupItem');
    if (Number(item_Id) > 0) {
      NWF$('#' + inputItem).val(item_Id);
    }
}

 

Thanks for any suggestion!

0 Kudos
Reply
jpmhuls
Workflow Veteran

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

Hi David,

My conclusion was that Nintex may have changed the setup of the List Lookup control in one of their updates; the control is a combination of (2 <input>) HTML elements which seem to have been re-arranged. As such previous JavaScript code no longer works. Have a look at my code to see if is of any help resolving your issue.

BR

0 Kudos
Reply
cwright
Nintex Newbie

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

That's a ridiculous argument, virtually all software solutions evolve and change. How that change is managed defines a professional approach from rank amateurs (Nintex). Nintex changed a software feature with a dependency effectively redefining the interface, haven't bothered to clearly notify their client base let alone give clear examples of how the change required should be implemented.

Nintex are a ****** shower of an organisation. We've come to the conclusion Nintex can't be trusted with even remotely business critical solutions.

Reply
dweyrick
Forms Fledgling

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

Using Nintex Forms 2013 v2.11.1.11 (Jan 2018) the following statment works to set the value of a Choice field drop-down list in a Nintex form:

NWF$('#' + fieldId).val(fieldvalue).change();

Note:  the .change() updates the selected value in the choice control AND triggers the recalculation of any calculated value fields tied to the Choice drop-down list value.

Took me many sets of trial and error to see what would work for this since my updated Nintex version (which affected Javascript according to the Release notes).

Hope this helps.

Reply
sojanm
Workflow Veteran

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

Hi David, 

The above mentioned "fieldId" , is it a javascript control name or the field name itself connected the control.

0 Kudos
Reply
dweyrick
Forms Fledgling

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

It is the javascript ID name you assigned to the control in the Advanced section of the control properties.

0 Kudos
Reply
jpmhuls
Workflow Veteran

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

And in runtime it contains the actual control DOM id, which may look like the following example: ctl00_ctl38_g_284b4677_5f42_4a00_bf38_f9516134732b_ctl00_ListForm1_formFiller_FormView_ctl18_ctl16_ctl16_86f210d1_ee13_49e5_9d79_cd44f49ef84f

0 Kudos
Reply
sojanm
Workflow Veteran

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

Thanks, I have Nintex Forms 2013 v2.11.1.0 and it seems it is working.

0 Kudos
Reply
sojanm
Workflow Veteran

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

Sorry it seems NOT working

0 Kudos
Reply
jpmhuls
Workflow Veteran

Re: How to correctly set dropdown value using JavaScript?

Jump to solution

Hi David,

Either Nintex changed in Nintex 2013 Forms v2.11.2.2 again, or I'm doing something wrong, but it does not seem to work for me. Would this also update the control itself and show a checked box for the set choice?

0 Kudos
Reply