RE: Java Script for a form to update a Case field with an Owner's field
Thank you Adrian - I have now ticked the box. The issue now is it does not seem to do anything.
I presume I have something wrong in my code.
Basically I only changed where it stated fieldName to new_alsbusinessstream and for the destination field on the form - new_ownersalsbusinessstream.
Isn't that correct?
Here it is:
function getValueFromOwnerLookUp(executionContext){
var formContext=executionContext.getFormContext();
//get lookup field
var Lookup_Cat=formContext.getAttribute("ownerid");
if(Lookup_Cat!=null){
//get lookup field record id
var value=Lookup_Cat.getValue();
var id=value[0].id;
//use record id to retrieve other field value
Xrm.WebApi.retrieveRecord("systemuser",id,"?$select=new_alsbusinessstream").then(
function success(result){
//get the systemuser field value and set it to field on case
var fieldValue=result.new_alsbusinessstream;
formContext.getAttribute("new_ownersalsbusinessstream").setValue(fieldValue);
},
function (error){
console.log(error.message);
}
)
}
}