I will tried to this code.
function getBranchdetails()
{
var Lookup=Xrm.Page.getAttribute("parentcustomerid").getValue();
var id=Lookup[0].id;
alert(id);
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/sbl_branchs(guid""+id"")?$select=sbl_branch_name,sbl_branchid,sbl_name&$count=true", 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=\"*\",odata.maxpagesize=5000");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var results = JSON.parse(this.response);
var recordCount = results["@odata.count"];
for (var i = 0; i < results.value.length; i++) {
var b_name = results.value[i]["sbl_branch_name"];
Xrm.Page.getAttribute("sbl_branch_name").setValue(b_name);
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}
But i have an error.
Script Error
One of the scripts for this record has caused an error. For more details, download the log file.
ReferenceError: getBranchdetails is not defined at eval (eval at RunHandlerInternal (skbsolution.crm8.dynamics.com/.../ClientApiWrapper.aspx), <anonymous>:1:1)