locked
Get guid of lookup value after fetching it via fetchxml RRS feed

  • Question

  • Hi,

    i am retrieving a record using fetchxml based on a guid. The fetch works perfectly but i cannot get the values of lookup attribute.

    here is my code

    var _oService;
    	var _sOrgName = "CRMTEST";
    	var _sServerUrl =Xrm.Page.context.getServerUrl();	
    	var sFetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
      "<entity name='new_mbasession'>"+
    "<attribute name='new_mbasessionid' />" +
        "<attribute name='new_name' />" +
          "<attribute name='new_university'/>"+
        "<order attribute='new_name' descending='false' />"+
        "<filter type='and'>"+
          "<condition attribute='new_mbasessionid' operator='eq' value='" + id2 + "' />"+
        "</filter>"+
      "</entity>"+
    "</fetch>";
    
    	_oService = new FetchUtil(_sOrgName, _sServerUrl);
    	_oService.Fetch(sFetch, myCallBack);
    }
    	
    	function myCallBack(results)
    {
    	var university = results[0].attributes["new_university"].value;     
                          
    }

    how do I get the guid of the lookup attribute new_university?? It shows undefined in this case.

    and if I read any other attribute it shows the desired value.

    Plz Help

    Thanks

    HARIS ADIL


    e-Biz


    • Edited by Harispk Wednesday, May 9, 2012 11:48 AM
    Wednesday, May 9, 2012 11:35 AM

Answers

  • Hi,

    Thanks for the reply. I was already following these posts. To read look-up(entity reference) values following helped:

    case “a:EntityReference”:
    var entRef = new jsEntityReference();
    entRef.type = sType;
    entRef.guid = attr.childNodes[k].childNodes[1].childNodes[0].text;
    entRef.logicalName = attr.childNodes[k].childNodes[1].childNodes[1].text;
    entRef.name = attr.childNodes[k].childNodes[1].childNodes[2].text;
    obj[sKey] = entRef;
    break;

    var university = results[0].attributes["new_university"].guid;

    It simply gave me the id .:)


    e-Biz

    • Marked as answer by Harispk Wednesday, May 9, 2012 12:23 PM
    Wednesday, May 9, 2012 12:23 PM

All replies