Skip to main content
Nintex Community Menu Bar

Set default value of List Lookup control using QueryString parameter

  • August 22, 2019
  • 1 reply
  • 29 views

Forum|alt.badge.img

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

4065i433460257D0573B7.png4064iE2C3420A8336F9CF.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&TofA=NON%20EMPLOYEE&Job=650258%20%2D%20PC%20Tech&Dept=1362%20%2D%20Tech%20Support&Company=My%20Company

 

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!

 

 

 

 

1 reply

Forum|alt.badge.img+10
  • October 17, 2019
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();