Set a Large Lookup Dynamically

I'm trying to set a lookup field dynamically using the value instead of the ID.
I'm using this method:

field.widget.bind("dataBound", function() {
var lookups =;
for (i = 0; i < lookups.length; i++) {
if (lookups[i].LookupValue == "Your text value") {
field.value = lookups[i].LookupId;

Taken from: Dynamically update Lookup Column - #2 by AlexZver (thank you :slight_smile: )

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.

Hello @teddy0bear,

You can filter list items by any field and get item ID using PnPjs library. Try out this code:

pnp.sp.web.lists.getByTitle('ListName').items.filter("Title eq " + fd.field("Title").value).get().then(function(items){
  fd.field('LookupField').value = items[0].Id