Hi there,
I'm just learning to get into the use of Odata. So far, so good...
But I tried to get the value of the industrycode (Optionset) of an account, but I don't get it. The Popup (alert) just shows me "undefined".
Could you please help me solve this problem? This would be perfect! It's just a really simple code for just playing around and learn.
var serverUrl = Xrm.Page.context.getClientUrl(); var queryUrl = serverUrl + "/xrmservices/2011/OrganizationData.svc/AccountSet?$select=Name,CreatedOn"; var req = new XMLHttpRequest(); req.open("GET", queryUrl, false); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.setRequestHeader("Prefer", "odata.include-annotations=OData.Community.Display.V1.FormattedValue"); req.send(); var results = JSON.parse(req.responseText).d.results; for (i=0;i<results.length;i++){ if(results[i]["Name"] == "Test Account"){ var nametest = results[i]["Name"]; var createdwhen = results[i]["CreatedOn"]; var industrycode = results[i]["IndustryCode"]; var industrycode_formatted = results[i]["industrycode@OData.Community.Display.V1.FormattedValue"]; alert(nametest); alert(createdwhen); alert(industrycode_formatted); } }
*This post is locked for comments