web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

How to set lookup field value using JavaScript Dynamics CRM

gdas Profile Picture gdas 50,091 Moderator

Setting lookup field value its not simple way you have to set three parameters to set the lookup value those are follows –

  1. GUID of the lookup record
  2. Name of the lookup record
  3. Entity Name of the lookup which entity the lookup record is belongs to.

Here is sample code how to set the lookup value using JavaScript Dynamics CRM.

var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = "{727504ed-64c5-4bc8-ac22-0a3071c427e3}"; // GUID of the lookup id
lookupValue[0].name = "Goutam Das"; // Name of the lookup
lookupValue[0].entityType = "contact"; //Entity Type of the lookup entity
Xrm.Page.getAttribute("FieldName").setValue(lookupValue); // You need to replace the lookup field Name..


Hope this helps :).

Comments

*This post is locked for comments

  • salman.syed Profile Picture salman.syed
    Posted at
    @SN_Dwivedi: What Goutam mentioned was about setting a lookup value not getting them, so based on your requirement to get lookup value its different to what he mentioned above and yes the article you have highlighted does the trick
  • SN Dwivedi Profile Picture SN Dwivedi 20
    Posted at
    I tried it but I was not able to get and set the lookup field. May be I was not understanding your code much but later I found this article they have explained everything well. blog.infobitsoft.com/.../how-to-get-and-set-lookup-field-using.html