Not applicable

Set pre selected value in a Lookup Dropdown

Hi, I have a list lookup control in the list. I want that when I open the edit form the value if this column will be pre-selected with the value already in the list for this item. But I am not able to implement this. I tried the Java Script for this as well. Please suggest me how to do this.

Thanks

Ratnesh

0 Kudos
Reply
12 Replies
philipplucas
Automation Master
Automation Master

Re: Set pre selected value in a Lookup Dropdown

If I understood you correctly, you want your list lookup control to have a preselected value?! But I can't get it to work either.

I tried:

$(".listlookup").val("14"); and

$(".listlookup option[value='14']").prop("selected", true);

If I do a alert($(".listlookup").val()); afterwards, I get the correct result ("14"). But the control is still showing "Please select a value".

Maybe some NintexForm-JS-Pro can have a look at this. For a regular dropdown, this should be working (see Edit fiddle - JSFiddle )​.

0 Kudos
Reply
Not applicable

Re: Set pre selected value in a Lookup Dropdown

Hi Philipp Lucas

This is exactly what I am facing. I know how to achieve this for regular drop downs but somehow it is not working for the Lookup List control.

0 Kudos
Reply
janeyres
Nintex Newbie

Re: Set pre selected value in a Lookup Dropdown

Hi,

This should work for you, assign the ID of the list lookup to a JavaScript variable (myLookupID in my example below).

NWF.FormFiller.Events.RegisterAfterReady(function(){

var yourText = "your text to select";

NWF$("#" + myLookupID + " option:contains(" + yourText +")").attr("selected", true);

});

Hope that helps.

Jan

0 Kudos
Reply
philipplucas
Automation Master
Automation Master

Re: Set pre selected value in a Lookup Dropdown

Hi Jan,

thanks for the hint. For me that doesn't work either. Did you test it? Is it working on your form?

0 Kudos
Reply
christopheraucq
Automation Master
Automation Master

Re: Set pre selected value in a Lookup Dropdown

Is the issue not linked to the fact the list of values is not filled in when the javascript is run?

0 Kudos
Reply
janeyres
Nintex Newbie

Re: Set pre selected value in a Lookup Dropdown

Hi,

Yes I tested it out, works ok for me with Nintex 2013 on premise.

Jan

0 Kudos
Reply
philipplucas
Automation Master
Automation Master

Re: Set pre selected value in a Lookup Dropdown

If i put that code into a function and execute it on a  button click, it works. But in the RegisterAfterReady event it doesn't (seems like Christophe Raucq​ has a point here).

Does anyone have an idea on this issue?

0 Kudos
Reply
Not applicable

Re: Set pre selected value in a Lookup Dropdown

Hi Jan,

Didn't worked for me either. Mine is also Nintex 2013 on premise.

0 Kudos
Reply
janeyres
Nintex Newbie

Re: Set pre selected value in a Lookup Dropdown

Can you post the lookup text and values that you are using?

Thanks

Jan

0 Kudos
Reply