Announcements
No record found.
hi,
i get lookup filed value and set in single line of text field through java script in on save event.
when there is no value in lookup field on save its throwing error like " can not ready property "0" or null.
Please help.
below screen shots of code and error for reference.
Hello,
Try to replace lookupfield.getValue with lookupfield.getValue()
if(lookupfield.getValue() != null && lookupfield.getValue()[0] != null){
var lookupname = lookupfield.getValue()[0].name;
}
The above should solve the issue, in your logic if(lookupfield.getValue != null) it only checks if array object exists, but fails to check if any elements exists in array before you call name property on 0th element.
Regards,
Praveen Thonda
D365 Support Engineer
Microsoft Corporation
Hi partner,
You should replace the "getValue" with "getValue()" in the condition.
"can not read property 0" means "lookupfield.getValue()" is null, which means your lookup field may not contians value.
About how to use js to work with lookup field, please refer to the following code.
Best Regards,
Leo
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
ManoVerse 184 Super User 2026 Season 1
11manish 125
CU11031447-0 100