RE: Problem with nested Xrm.WebApi.retrieveRecord in UCI
Thanks for the reply Andrew -
function Lead_OnChange_Contact(executionContext) {
var formContext = executionContext.getFormContext != null ? executionContext.getFormContext() : executionContext;
var creation = 1;
if (formContext.ui.getFormType() == creation && formContext.getAttribute('cw_employeereferral').getValue() == true) {
var contactid = formContext.getAttribute("parentcontactid").getValue()[0].id;
Xrm.WebApi.retrieveRecord("contact", contactid, "?$select=_parentcustomerid_value, firstname, lastname, fullname")
.then(function (contact) {
var accountid = contact["_parentcustomerid_value"];
formContext.getAttribute('firstname').setValue(contact["firstname"]);
formContext.getAttribute('lastname').setValue(contact["lastname"]);
formContext.getAttribute('fullname').setValue(contact["fullname"]);
Xrm.WebApi.retrieveRecord("account", accountid, "?$select=name")
.then(function (account) {
formContext.ui.setFormEntityName("Employee referral from " + Xrm.Utility.getGlobalContext().userSettings.userName + " to " + account.name);
})
})
}
}