I have some JavaScript that does a setFormEntityName, works fine in classic interface but not working in the Unified Interface.
Looks like this is down to having a nested Xrm.WebApi.retrieveRecord. We are retrieving a contact record, getting accountid from that and when retrieving an account record and using the account name in setFormEntityName
The second nested Xrm.WebApi.retrieveRecord just doesn't work in the UCI, but is fine in classic interface, does anyone know if tis is a known issue/
Thanks
Many thanks, no idea why the nested call isn't working in the UCI but you're right, we don't need it anyway. Got it working now without it :)
Hello,
I don't see any issue in the code. One thing that I wanted to notice is that you have no need to do the second retrieve because name of the company is already in the response and you can get it using following line:
var accountName = contact["_parentcustomerid_value@OData.Community.Display.V1.FormattedValue"];
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);
})
})
}
}
Hello,
Can you please provide code you use?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156