Skip to main content



No record found.

Microsoft Dynamics CRM forum

Auto-Populate free text field with Lookup Value

Posted on by Microsoft Employee

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 ="new_contactnameid").getValue()[0].name;
var ContactNameId ="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;


For some reason I keep getting the error "invalidType".

Thanks in advance.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Auto-Populate free text field with Lookup Value

    Thanks Ravi, it worked!

  • Verified answer
    RaviKashyap Profile Picture
    RaviKashyap 55,406 on at
    RE: Auto-Populate free text field with Lookup Value


    try this-

    function AutoName(){

    var ContactName ="new_contactnameid").getValue()[0].name;



    Hope this helps.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,986 Super User

Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans