How to get guid id by using Json and odata RRS feed

  • Question

  • Hi,

    I want to get GUID of territory ID of systemUserSet by using Json and odata.  Please find below jscript used of getting this but I am getting Firstname correctly as first name of user and objectid as shown below image against result of alerts in the scripts

    clientid = Xrm.Page.context.getUserId();
    var context = Xrm.Page.context;
    serverUrl = context.getServerUrl(); 
    var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
    var retrieveResult = new XMLHttpRequest();
    retrieveResult.open("GET", ODataPath + "/SystemUserSet?$select=FirstName,TerritoryId&$filter=SystemUserId eq guid'" + clientid + "'", false);
    retrieveResult.setRequestHeader("Accept", "application/json");
    retrieveResult.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    if (retrieveResult.readyState == 4 )
       if (retrieveResult.status == 200)
                var retrieved = JSON.parse(retrieveResult.responseText).d;

           var  terid = retrieved.results[0].TerritoryId;
           var  fname = retrieved.results[0].FirstName;


    fname     GP


    but I need to get not object the GUID value  as shown below screen.  How I can get this.  Kindly help me.


    • Edited by P Noushad Wednesday, February 1, 2017 1:54 PM
    Wednesday, February 1, 2017 1:43 PM

All replies

  •  var  terid = retrieved.results[0].TerritoryId.Id;


    Thursday, February 2, 2017 6:24 AM