web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

What To Do With a Dynamics 365 Lookup OnChange Event Error

MagnetismXRM Profile Picture MagnetismXRM 6,230

I recently came across an odd JavaScript error for the onChange event of a lookup field in Dynamics 365. Apparently, removing the lookup item from the field works fine if it’s being removed directly from the form, however, when removing it from the ‘Look Up Record’ dialog box (see below), a JavaScript error “Unable to get property ‘id’ of undefined or null reference” pops up.

clip_image002

The same JavaScript onChange event is being called from the ‘Look Up Record’ dialog box and from the form. For the latter scenario, getValue method returns ‘null’ on removing the item from the lookup field but the same method returns an empty array when removing it from the ‘Look Up Record’ box. Hence, the JavaScript error pops up.

Therefore, if you encounter this error on a LookUp onChange event, make sure you’re checking the ‘null’ value for the first array element in your code as below:

clip_image003

Comments

*This post is locked for comments