locked
how to access null values in oData Query RRS feed

  • Question

  • Hi,

    I am trying to retrieve odata query results and access them by storing in an array.

    But my results do contain null values and when I debug the script I am seeing this error.

    "unable to get property of FullName undefined or null reference javascript".

    Here is one of my functions in the script:

    function RetrieveName()
     {
    debugger;
       var ClientUrl=Xrm.Page.context.getClientUrl();
       var oData_EndPoint="/XRMServices/2011/OrganizationData.svc";
       var oData_EntityCollection="/new_securitySet";
       var Query="?$select=new_systemuser_new_security_MemberExclusion/FullName,new_team_new_security_TeamExclusion/Name&$expand=new_systemuser_new_security_MemberExclusion,new_team_new_security_TeamExclusion";
       var URL=ClientUrl+oData_EndPoint+oData_EntityCollection+Query;
    
       //synchronous XMLHttpRequest to retrieve account record
       var req=new XMLHttpRequest();
       req.open("GET",encodeURI(URL),false);
       req.setRequestHeader("Accept","application/json");
       req.setRequestHeader("Content-Type","application/json;charset=utf-8");
       req.send(null);
       var records = JSON.parse(req.responseText).d;
      
      var arr=[];
      for(var i=0;i<records.results.length;i++)
      {
      arr.push(records.results[i].new_systemuser_new_security_MemberExclusion.FullName);
      
      //var securityEntity=records.results[i];
      //alert(securityEntity.new_systemuser_new_security_MemberExclusion.FullName);
      }
    alert(arr);
      }

    How can I access all the results including null values?

    Thanks for any help!

    Monday, August 4, 2014 3:09 PM

Answers

  • Hi,

    Did you try this ?

    if(records.results[i].new_systemuser_new_security_MemberExclusion != null)
    {
    arr.push(records.results[i].new_systemuser_new_security_MemberExclusion.FullName)
    }
    


    Thanks and Regards. Make sure to &quot;Vote as Helpful&quot; and &quot;Mark As Answer&quot;,if you get answer of your question.

    • Marked as answer by ReignFan Monday, August 4, 2014 6:51 PM
    Monday, August 4, 2014 4:14 PM

All replies

  • Hi,

    Did you try this ?

    if(records.results[i].new_systemuser_new_security_MemberExclusion != null)
    {
    arr.push(records.results[i].new_systemuser_new_security_MemberExclusion.FullName)
    }
    


    Thanks and Regards. Make sure to &quot;Vote as Helpful&quot; and &quot;Mark As Answer&quot;,if you get answer of your question.

    • Marked as answer by ReignFan Monday, August 4, 2014 6:51 PM
    Monday, August 4, 2014 4:14 PM
  • Hi,

    Did you try this ?

    if(records.results[i].new_systemuser_new_security_MemberExclusion != null)
    {
    arr.push(records.results[i].new_systemuser_new_security_MemberExclusion.FullName)
    }
    


    Thanks and Regards. Make sure to &quot;Vote as Helpful&quot; and &quot;Mark As Answer&quot;,if you get answer of your question.

    Monday, August 4, 2014 4:14 PM