Hi Suchi,
Write a function on onchange on your field "AccountNumber".
//This will retreive the account record id which having details of your feilds : ParentAccount,Top Level PAL ....
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts?$filter=accountnumber eq ' **Pass Your accountnumber** '", true);
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=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);
for (var i = 0; i < results.value.length; i++) {
var accountid = results.value[i]["accountid"];
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
// Retreive the values of the fields
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts(accountid)?$select=description,_parentaccountid_value", true); // select your fields
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=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var result = JSON.parse(this.response);
var desc = result["description"]; // get the values of selected fields..
var _parentaccountid_value = result["_parentaccountid_value"]; // get the values of selected fields..
var _parentaccountid_value_formatted = result["_parentaccountid_value@OData.Community.Display.V1.FormattedValue"];
var _parentaccountid_value_lookuplogicalname = result["_parentaccountid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
// Set your current attributes values
Xrm.Page.getAttribute("description").setValue(desc);
Xrm.Page.getAttribute("").setValue();
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
Please mark the answer as verified, if found useful.
Thanks,
Pankaj