function GetAccountdetails() {
var lookup = Xrm.Page.getAttribute("new_accounts").getValue();
var id = lookup[0].id;
var Fetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name='new_testcrm'>"+
"<attribute name='new_testcrmid' />"+
"<attribute name='new_name' />"+
"<attribute name='createdon' />"+
"<order attribute='new_name' descending='false' />"+
"<link-entity name='account' from='accountid' to='new_accounts' link-type='inner' alias='ab'>"+
"<filter type='and'>"+
"<condition attribute='accountid' operator='eq' uitype='account' value='" + id + "' />" +
"</filter>"+
"</link-entity>"+
"</entity>"+
"</fetch>";
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/new_testcrms?fetchXml=" + encodeURI(Fetch), true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function () {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
debugger;
var results = JSON.parse(this.response);
var new_dob1 = results.value[0]["new_name"];
var new_dob2 = results.value[0]["createdon"];
alert(new_dob)
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}
No comments:
Post a Comment