lucylee7

How to set default for a lookup column using jquery in nintex

Discussion created by lucylee7 on Mar 23, 2018
Latest reply on Jul 17, 2018 by michaela

I was wondering anyone could shed some lights on this.

 

I want to set default to EN ENGLISH on my list lookup (Language) as below but its editable.

 

 

 

JQuery

NWF$(document).ready(function() {   
 
  //setLookupField(DetailLanguage, 'EN ENGLISH');
}); NWF.FormFiller.Events.RegisterAfterReady(function () {
 
 if (DetailLanguage == "Please select a value..."){
 
 setLookupField(DetailLanguage, 'EN ENGLISH');
    setTimeout(function(){ setLookupField(DetailLanguage, 'EN ENGLISH')},1000);
    setTimeout(function(){ setLookupField(DetailLanguage, 'EN ENGLISH')},2000);
 }else{
  setLookupField(DetailLanguage, 'EN ENGLISH');
    setTimeout(function(){ setLookupField(DetailLanguage, 'EN ENGLISH')},1000);
    setTimeout(function(){ setLookupField(DetailLanguage, 'EN ENGLISH')},2000);
  
 }});
function setLookupField(lookupField, lookupValue) {
 var lookupID = lookupField.substring(0, lookupField.length-4);
 var selectField = NWF$("#" + lookupID + " > option");
 
 for (var i = 0; i < selectField.length; i++){
  var option = selectField[i];
  if(option.text == lookupValue){
   NWF$("#" + lookupID).val(option.value);
   NWF$("#" + lookupField).val(option.getAttribute("data-nfchoicevalue"));
   NWF$("#" + lookupField).trigger("change");
   NWF$("#" + lookupField).trigger("blur");
   break;
  }
 }
}

Outcomes