Lookup field initial value from pnp

Hi,

I'm wondering if it's possible, to have prefetched lookup value that I get from external list?
At first i get currentUser email through PnP, then I filter the employee list with this email and then i get the item.

From this item I want to take "InvertNameAndGID" and set it as:
fd.control('lookUser').value = userData.InvertNameAndGID;
when form is initialized, so it is pre-written and also could be changed, if user isn't same as requestor. And also on the lookup value are depended extra fields, that I'm using for other columns.

Any sugestions please? Or is there any cleaner way? Thx in advance!

First image is how it works now, second image is desired effect what I want to see when form is incialized.




image

Hi @Multihunter,

You can't set the Lookup value directly, instead, you need to give it the option ID. My only suggestion is to try going over all possible lookup values in a cycle to find the one that corresponds to the pre-fetched value.

1 Like

Hi @Multihunter ,

Yes, as @IliaLazarevskii typed in the previous comment.

Fetch the data from the list you have in site content and return back the ID for a specific user based on your/logged in user. Then the value for a user is changed and you can chain the functions to load the data of "prefetched" user that had been loaded to the form to "User" field.

That is probably the best way to achieve this goal.

Regards
Stepan

1 Like