Querying the stringmapset with odata RRS feed

  • Question

  • I have a dropdown box on a form and I need to set this automatically based upon a text field, the dropdown is a lookup so my intention is to do the following:

    * Query the Accountset to retrieve the role for the account.

    * query the stringmap table to retrieve the correct label for this  role.

    *Set the dropdown with the correct role.

    So far I have the following which returns the role code for the account, but when I try to query the stringmapset I receive an error.  Is there a better way of doing this or returning the correct name and setting the dropdown?

    function AccountRole(AccRole)
        var serverUrl = document.location.protocol + "//" + document.location.host + "/" + Xrm.Page.context.getOrgUniqueName();
        var oDataEndpointUrl = serverUrl + "/XRMServices/2011/OrganizationData.svc/";
        oDataEndpointUrl += "AccountSet?$select=orb_globalaccounttypecode,orb_AccountTypecode&$filter=Name eq '"+AccRole+"'";
        var service = GetRequestObject();
        if (service != null)
            service.open("GET", oDataEndpointUrl, false);
            service.setRequestHeader("X-Requested-Width", "XMLHttpRequest");
            service.setRequestHeader("Accept", "application/json, text/javascript, */*");
            var requestResults = eval('(' + service.responseText + ')').d;
            if (requestResults != null && requestResults.results.length > 0)
                var QuotePots = "";
                for (var i = 0; i < requestResults.results.length; i++) // fetch the results
        return false;



    Thursday, December 4, 2014 3:59 PM