Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 2013 odata Request not working

$
0
0

Hi, Can someone review and let me know why this query isn't working?

theirs a field called new_task on the account and the same one on the Task entity, the optionssets are global so have the same values.

function setType() {
    var lookup = Xrm.Page.getAttribute("regardingobjectid").getValue();
    if (lookup != null) {
        var lookupid = lookup[0].id;

        var serverUrl;
        if (Xrm.Page.context.getClientUrl !== undefined) {
            serverUrl = Xrm.Page.context.getClientUrl();
        } else {
            serverUrl = Xrm.Page.context.getServerUrl();
        }

        var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
        var dataRequest = new XMLHttpRequest();
        dataRequest.open("GET", ODataPath + "/AccountSet(guid'" + lookupid + "')", false);
        dataRequest.setRequestHeader("Accept", "application/json");
        dataRequest.setRequestHeader("Content-Type", "application/json; charset=utf-8");
        dataRequest.send();
        if (dataRequest.status === 200) {
            var retrievedValue = JSON.parse(dataRequest.responseText).d;

            var value = retrievedValue.new_type;
            Xrm.Page.getAttribute("new_type").setValue(value);
            Xrm.Page.getAttribute("new_type").setSubmitMode("always");
        }
        else {
            return "error";
        }
    }
}



Pete



Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>