Good morning all,
I'm trying to auto populate a free text field with the value of a lookup, i.e. populate Joe Smith in the free text field based on the look up value Joe Smith.
I've tried this code:
function AutoName(){
var ContactName = Xrm.Page.data.entity.attributes.get("new_contactnameid").getValue()[0].name;
var ContactNameId = Xrm.Page.data.entity.attributes.get("new_contactnameid").getValue()[0].id;
ContactNameId = ContactNameId.replace('{', '').replace('}', '');
var entityType = "contact";
var LookupValue = new Array();
LookupValue[0] = new Object();
LookupValue[0].id = ContactNameId;
LookupValue[0].name = ContactName;
LookupValue[0].entityType = entityType;
Xrm.Page.getAttribute("new_name").setValue(LookupValue);
}
For some reason I keep getting the error "invalidType".
Thanks in advance.
*This post is locked for comments
I have the same question (0)