How to check for null attributes before referencing them after fetching it via fetchutility?? RRS feed

  • Question

  • Hi,

    I am fetching attributes using javascript on the OnChange event and filling up other fields. But i get an error if some attributes are null.

    Is there a way to check for null attributes before referencing them like in C# we have Entity.attributes.contains("fieldname") method to check for null values.


    Haris Adil e-Bizsoft

    Friday, May 25, 2012 3:18 PM


All replies

  • Hi,

    Are you getting value from database using javascript then you can check something like below

     var resultset= this.parent.JSON.parse(retrieveReq.responseText).d;
                if (retrievedAccount.<SchemaNameofField>!= null)

    {//fetch value


    if you are reading value from fields directly you can try

    if (Xrm.Page.getAttribute("FieldName").getValue() != null) {



    Mahain : Check My Blog
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, May 25, 2012 3:31 PM
  • Hi Mahender,

    I am using the following fetch utility


    I have got rid of the error by using try catch statement.

    Thanks for your reply. 

    Haris Adil e-Bizsoft

    • Edited by Harispk Friday, May 25, 2012 3:35 PM
    • Marked as answer by Harispk Tuesday, June 19, 2012 1:01 PM
    Friday, May 25, 2012 3:35 PM