I have given the input to the respective field but its not updating. I am pasting the full script for your reference.
function RebateToOfg()
{
if(Xrm.Page.getAttribute("header_new_customername") != null){
{
var vOppid1 = Xrm.Page.getAttribute("new_new_test123_new_rebateapprovalsoas").getValue()[0].id;
vOppid1 = vOppid1.replace("{","").replace("}","");
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/opportunities?$select=_contactid_value,_customerid_value,description,name&$filter=opportunityid eq "+vOppid1+"", 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 _contactid_value = results.value[i]["_contactid_value"];
var _contactid_value_formatted = results.value[i]["_contactid_value@OData.Community.Display.V1.FormattedValue"];
var _contactid_value_lookuplogicalname = results.value[i]["_contactid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
var _customerid_value = results.value[i]["_customerid_value"];
var _customerid_value_formatted = results.value[i]["_customerid_value@OData.Community.Display.V1.FormattedValue"];
var _customerid_value_lookuplogicalname = results.value[i]["_customerid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
var description = results.value[i]["description"];
var name = results.value[i]["name"];
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
if (result != null) {
if ((result[0].value[0].header_new_customername) != null)
{
var _CustomerNameObj = (result[0].value[0].header_new_customername);
var _CustomerNameValue = _CustomerNameObj._CustomerNameObj[0].name;
Xrm.Page.getAttribute("header_new_customername").setValue(_CustomerNameValue[0].name);
}
}
}
}
}