Hi, we are using CRM Online version 9.1.
This is the code I usually use for populating value from one entity to another.
function populateInvoicingDetails()
{
if(Xrm.Page.getAttribute("customerid").getValue()!=null)
//read
var opportunity = Xrm.Page.getAttribute("customerid").getValue()[0].id;
var opportunityId = opportunity.substring(1, 37);
opportunityId = opportunityId.replace('{', '').replace('}', '');
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/accounts(" + opportunityId + ")?$select=new_invoicetocontactname", 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 result = JSON.parse(this.response);
var oppnumber1 = result["new_invoicetocontactname"];
// Replace with the actual field names of the email address and phone number in custom entity
Xrm.Page.getAttribute("new_invoicetocontactname").setValue(oppnumber1);
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}I need to populate 6 values from Accounts to Invoice entity. I have created fields and mappings between the fields.
This works perfectly fine for one field.
How can I use this for multiple fields? I tried changing the code but could not make it work.
Thanx.









