Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Auto-Populate free text field with Lookup Value

$
0
0

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.


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images