I am trying to update some fields on a customer entity form with the data gathered from the account lookup on the form.
Now i need to get the system user values of the 2 customer field on the account table (cr787_Partner and cr787_Manager) and use those values to populate a Job_Partner field and a Job_Manager field (both custom) when the account field changes.
Now here is what i have so far in jscript
function setPartnersandManagers() {
var account = Xrm.Page.getAttribute("cr787_accountcode").getValue()
if (account != null){
var accountId = Xrm.Page.getAttribute("cr787_accountcode").getValue()[0].id;
alert(accountId);
Xrm.WebApi.retrieveRecord("account", accountId, "?$select=name,revenue,cr787_Partner,cr787_Manager,ownerid").then(
function success(result) {
alert("Retrieved values: Name: " + result.name + ", Revenue: " + result.revenue);
var partner = result.cr787_Partner;
var name = partner.Name;
alert(name);
// perform operations on record retrieval
},
function (error) {
alert(error.message);
// handle error conditions
}
);
}
}
I can get the retrieveRecord to pull back a record but it appears that the cr787_Partner and Manager fields return undefined when i try to display them in an alert. Now i figure that is because they are lookups themselves.
I can't for the life of me figure out how to get these values and set the values of the two fields on the form.
Any help greatly accepted
Thanks in advance
Matt