Notifications
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 70 Super User 2025 Season 2
Gerardo RenterÃa Ga... 33 Most Valuable Professional
Daniyal Khaleel 32 Most Valuable Professional