locked
problem when retrieving entity reference from another entity RRS feed

  • Question

  • hi frnds,

    when i retrieve entity reference value from another entity i cant get the name and id of the field.. it retruns the object but if am doing object.id it saying undefined.my code is

    populatewithconnectiondata = function (){
     
       
        var odataSelect = "http://XXX:5555/XXX/xrmservices/2011/OrganizationData.svc/ConnectionSet?$select=Record2Id&$filter=Record2RoleId/Id eq guid'F55E1379-FD99-E011-9939-000C2917832C' and Record1Id/Id eq guid'0D84F247-4686-E011-B58D-000C2917832C'"
     
    $.ajax({
            type: "GET",
            contentType: "application/json; charset=utf-8",
            datatype: "json",
            url: odataSelect,
            beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); },
            success: function (data, textStatus, XmlHttpRequest)
               {
                   
    // Use this method for a selection that  return single entity
             RetrieveEntityData(data.d);
                      
               },
            error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: ' + odataSelect); }
        });
     }


    function RetrieveEntityData(ManyEntities){
    for( i=0; i< ManyEntities.length; i++)
     var oneEntity = ManyEntities[i];
     var ConnectedContactId = oneEntity.Record2Id.Id;

     alert(ConnectedContactId)/here saying undefined
    }
     }

    pls give mea solution as soon as possible thanx in advance


    Arun Kumar G


    • Edited by Aronkumar Friday, July 5, 2013 11:34 AM
    Friday, July 5, 2013 11:33 AM

Answers

  • Try

     alert(oneEntity.Record2Id.Id);

    OR

    var ConnectedContactId = oneEntity.Record2Id;
    
     alert(ConnectedContactId.Id)



    • Marked as answer by Aronkumar Saturday, July 6, 2013 5:01 AM
    Friday, July 5, 2013 2:53 PM

All replies

  • Try

     alert(oneEntity.Record2Id.Id);

    OR

    var ConnectedContactId = oneEntity.Record2Id;
    
     alert(ConnectedContactId.Id)



    • Marked as answer by Aronkumar Saturday, July 6, 2013 5:01 AM
    Friday, July 5, 2013 2:53 PM
  • the above code working fine thanx frnd...


    Arun Kumar G

    Saturday, July 6, 2013 5:01 AM