Untitled
unknown
plain_text
a year ago
980 B
7
Indexable
function autoPopulate(primarycontrol){
var customerValue = primarycontrol.getAttribute("").getValue();
//Get that record's parent account
var customerID = customerValue[0].id;
//Trim {} from the GUID
customerID = customerID.slice(1, -1);
Xrm.WebApi.retrieveMultipleRecords("account", "?$select=name&$filter=customerid eq " + customerID).then(
function success(result) {
var accountName = result.entities[0].name;
var accountID = result.entities[0].accountid;
//if account id contains {}, trim it
if(accountID.includes("{")){
accountID = accountID.slice(1, -1);
}
primarycontrol.getAttribute("").setValue([{name: accountName, id: accountID, entityType: "account"}]);
},
function (error) {
//Xrm.Navigation.openAlertDialog({ text: error.message });
alert("Error: " + error.message);
}
)
}Editor is loading...
Leave a Comment