Hi,
I have a nice working OnChange script event on a lookup field. It works fine in both of my test and prod environments.
Recently it started throwing this error "Unable to get property '0' of undefined or null reference" when one of the user tried to change this lookup field differently.
Instead of entering the data into the field and pressing enter or selecting the lookup to choose one of the values, user clicked tab after entering data so that he can enter data quickly.
But since it is a tab click my script is picking the lookup field value as 'null' and throwing this script error with a dialog box.(That is what I understood)
There was an error with this field's customized event.
Field:new_priority
Event:onchange
Error:Unable to get property '0' of undefined or null reference.
Interesting enough, the error is in test environment too but it does not pop up a dialog box and it is working fine unless I debug the page, I didn't knew the error was in there.
But in production, it is popping the error with a dialog box.
Can you please let me know how to proceed or what to look for.
Note: On debug I found the error on this line:
var priority=Xrm.Page.data.entity.attributes.get("new_priority").getValue()[0].name;
Thanks