I'm trying to set a lookup field dynamically using the value instead of the ID.
I'm using this method:
fd.field("Lookup").ready().then(function(field){
field.widget.bind("dataBound", function() {
var lookups = field.widget.dataSource.data();
for (i = 0; i < lookups.length; i++) {
if (lookups[i].LookupValue == "Your text value") {
field.value = lookups[i].LookupId;
break;
}
}
})
})
Taken from: Dynamically update Lookup Column - #2 by AlexZver (thank you )
And it does work, sort of...
My lookup list has over 1k items and if I set it with a value from the first 35 ish items, no problem, works perfectly. If I set it to a value after that it doesn't really work. When I open the form it will not populate up but if I click the look up and then scroll down to where the item is then I can see it's been highlighted and it will then populate. Is there a way to get it to auto populate regardless of which item?
I am expanding it to include 2 more columns should that contribute to anything and I'm plotting to put this in a onchange event once I get it working.