Tuesday, August 23, 2016

Dynamic CRM - Unable to get property 'value' of undefined or null reference.

In this post, I would like to talk about this error while executing a Fetch Xml through Xrm Service Toolkit (JavaScript).

There was an error with this field's customized event.
Field: window
Event: onload
Error: Unable to get property 'value' of undefined or null reference.

The script where the error occured is :

var resultset = XrmServiceToolkit.Soap.Fetch(strFetchXml);

Generally with the research it involved, I found various possibilities that could result in this error message (mainly being missing field in a given form / entity), but that was not the case for me. 

 After spending huge amount of time, it was found that the resultset after executing Fetch XML was null and this error message was part of Xrm Service Toolkit for handling returned data. 

To make it more clear, I added a try / catch for the above statement and added a not null condition for resultset.

if(resultset != null)

Above implemented action(s) made sure, it didn't throw any error messages and handled properly.

Happy coding....