HI Everyone
I am new to development and trying to get option set value from account to lead on existing account selection but my JS is not working , can any one suggest what is the mistake here:
function retrieveData(executionContext) {
debugger;
var formcontext = executionContext.getFormContext();
var accountId = formcontext.getAttribute("parentaccountid").getValue();
if (accountId != null) {
Xrm.WebApi.retrieveRecord("account", accountId[0].id, "?$select=name,ownershipcode").then(
function success(result) {
var accountOwner = result("ownershipcode@OData.Community.Display.V1.FormattedValue");
formcontext.getAttribute("new_ownership").setValue(accountOwner);
},
function (error) {
console.log(error.Message);
}
);
}
}