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