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

Select default in multiple list lookup

Jump to solution

Hi guys,

Im currently working on a Nintex form, where i want an item in my list lookup to be selected by default.

Thats an easy task if i use the "list" display format and use this script:

var findBank = ["Bank3"];

NWF$('#' + lookUpList + ' option').filter(function(){

       return findBank.indexOf(NWF$(this).text()) > -1;

}).prop('selected', true);


The problem is the customer wants the display format "default" beacuse Add/Remove selection box is much more user friendly.

So the question is: how do i make an item defualt added?

list lookup.PNG
It should look like the above when the form is opened.

Regards
Jens Bräuner

Labels: (3)
0 Kudos
Reply
4 Replies
janeyres
Nintex Newbie

Re: Select default in multiple list lookup

Jump to solution

Hi,

If you give your lookup control a class of multiChoice then paste the following script in the Custom JavaScript section in Form settings it should work:

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

NWF$(".multiChoice option:selected").removeAttr("selected");

var selval = NWF$(".multiChoice select:first-child option:contains('Bank3')").val();

NWF$(".multiChoice select:first-child option[value='" + selval + "']").attr('selected', 'selected');

NWF$(".multiChoice button:first-child").click();

});         

Hope that helps.

Jan

Reply
Not applicable

Re: Select default in multiple list lookup

Jump to solution

Awesome! Thank you so much, works perfectly!

I was also trying the "workaround" with the button click, but was missing :first-child in the selector.

Thanks Again.

Jens Bräuner

0 Kudos
Reply
chakri3458
Nintex Newbie

Re: Select default in multiple list lookup

Jump to solution

Not working to me.Please help me

NWF$(".multiChoice option:selected").removeAttr("selected");
var selval = NWF$(".multiChoice select:first-child option:contains('+QSWID+')").val();
 
NWF$(".multiChoice select:first-child option[value='" + selval + "']").attr('selected', 'selected');
NWF$(".multiChoice button:first-child").click();
0 Kudos
Reply
kdelcastillo
Nintex Newbie

Re: Select default in multiple list lookup

Jump to solution

I don't know if you ever figured this out but the missing piece was a trigger:

NWF.FormFiller.Events.RegisterAfterReady(function () {  
   /* Didn't need this line
   NWF$(".multiChoice option:selected").removeAttr("selected"); */

   var selval = NWF$(".multiChoice select:first-child option:contains('Bank3')").val();
   NWF$(".multiChoice select:first-child option[value='" + selval + "']").attr('selected', 'selected').trigger("change"); 
   NWF$(".multiChoice button:first-child").click();
});     ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
Reply