How to set lookup field value using JavaScript Dynamics CRM
Views (27642)
Setting lookup field value its not simple way you have to set three parameters to set the lookup value those are follows –
- GUID of the lookup record
- Name of the lookup record
- 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
-
@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
-
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
*This post is locked for comments