Setting value to lookup field in freedom ui client side coding
Hi Community,
Setting value to lookup field using below syntax is not working. It seems this attribute ("PDS_UsrType_kkjfk5h
") does not have value and displayValue properties. Any idea please?
request.$context.PDS_UsrType_kkjfk5h = {
value: "someId",
displayValue: "Some Value"
};
By the way, i am calling the above inside request: "crt.HandleViewModelInitRequest".
Like
That is the correct way to set a lookup. There's an issue that was introduced in 8.0.8, I've not re-tested since 8.1.1, but the values set in the init (and resume) requests are overwritten by the page setting the default values. It's completely aggravating. Anyway, try wrapping the set in a setTimeout to see if causing a slight delay works (assuming your attribute name is correct):
setTimeout(() => { request.$context.PDS_UsrType_kkjfk5h = { value: "someId", displayValue: "Some Value" }; }, 300);
Ryan
Ryan Farley,
Hi Ryan,
Thank you so much, the work around is working.