cancel
Showing results for 
Search instead for 
Did you mean: 
ktower
Nintex Newbie

Set default value of List Lookup control using QueryString parameter

I'm new to Nintex, so I'm hoping someone will be able to help. I'm sure I'm not trying to doing anything that hasn't been done before. 

Issue: I am unable to set the default value of a List Lookup control from a QueryString parameter, on the NewItem form, running on IE 11, eventhough, I can set the default of a Single Line Textbox control. I have verified that I can read the querystring and return the correct parameter value. I am able to decode the querystring parameter to replace %20 with spaces, etc.  Because I am using IE 11, I understand that I can't use the javascript find() method, to retrieve the ID for the text value of the parameter string. I’ve tried passing both the parsed parameter string value, as well as a hard-coded record ID, but neither changes the List Lookup field, even if I could retrieve the record ID. 

 

Form has a List Lookup control called JobTitle. JavaScript variable name is defaultJob. And, a Single Line Textbox control called txtJob. JavaScript variable name is qsJob

JobTitle List Lookup.pngtxtJob Single Line Text.png

 

 

 

 

 

 

 

 

 

 

 

 

 

This is the Javascript:

NWF.FormFiller.Events.RegisterAfterReady(function() {
JSRequest.EnsureSetup();
var paramJob= JSRequest.QueryString['Job'];
if(paramJob=="undefined")
{
alert("paramJob is empty");
} 
else
{
alert(paramJob);
paramJob = paramJob.replace(/%20/gi, " ");
paramJob = paramJob.replace(/%2D/gi, "-");
alert(paramJob);
var ddlJob = NWF$("#" + defaultJob);
var tbJob = NWF$("#" + qsJob);
//ddlJob.val(paramJob);
ddlJob.val('1') 
tbJob.val(paramJob);
alert("ddlJob = " + ddlJob.val());
NWF.FormFiller.Functions.ProcessOnChange(ddlJob);
NWF.FormFiller.Functions.ProcessOnChange(tbJob);
}
});

Here is a sample of the QueryString:

 

https://sharepointsite/Lists/ListName/NewForm.aspx?EmpNum=000000001&First=FirstName&Last=LastName&To...

 

The parsed querystring parameter for 'Job' reads 650258%20%2D%20PC%20Tech

After it's decoded it reads 650258 - PC Tech

The ID for this list item is 328

 

Thank you in advance for your suggestions!

 

 

 

 

Labels: (1)
0 Kudos
Reply
1 Reply
sojanm
Nintex Newbie

Re: Set default value of List Lookup control using QueryString parameter

Try this,
var value ="Job in the list" - should be the value without id.


NWF$('#' + defaultJob ).parent().find('select').find('option:contains("'+ value +'")').attr("selected", true);
NWF$('#' + defaultJob ).parent().find('select').change();
0 Kudos
Reply