Hi,
I want to get department name from ContactSet from opportunity form by filtering ParentCustomerId. But I am getting retrieveResult.status = 400. Please find below script and help me to find solution.
Calling from Opportunity form
var accountID= Xrm.Page.getAttribute("customerid").getValue()[0].id; (Potential customer from Opportunity)
var context = Xrm.Page.context;
serverUrl = context.getServerUrl();
var ODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
var retrieveResult = new XMLHttpRequest();
retrieveResult.open("GET", ODataPath + "/ContactSet?$select=new_Department&$filter=ParentCustomerId eq guid'" + accountID + "'", false);
retrieveResult.setRequestHeader("Accept", "application/json");
retrieveResult.setRequestHeader("Content-Type", "application/json; charset=utf-8");
retrieveResult.send();
if (retrieveResult.readyState == 4 )
alert("e");
{
if (retrieveResult.status == 200)
{
var retrieved = JSON.parse(retrieveResult.responseText).d;
alert(retrieved.results[0].new_Department)
}
}
*This post is locked for comments