"тнιѕ вℓσg ¢συℓ∂ ѕανє уσυя мσηєу ιƒ тιмє = мσηєу" - ∂.мαηנαℓу

Thursday, 31 March 2011

How to retrieve lookup text value / id using Javascript in CRM 2011 OR How to get lookup text value / Id in CRM 2011

Related Post: How to retrieve lookup attribute from Plugin in CRM 2011 

 http://crmdm.blogspot.com/2011/06/how-to-retrieve-lookup-attribute-from.html  


Code Snippet:

var lookupObject = Xrm.Page.getAttribute("yourlookupattributename");

    if (lookupObject != null)
  {

        var lookUpObjectValue = lookupObject.getValue();

        if ((lookUpObjectValue != null))
        {

         var lookuptextvalue = lookUpObjectValue[0].name;

         var lookupid = lookUpObjectValue[0].id;

        }

  }

6 comments:

  1. I want to retrieve lookup value from .net code

    ReplyDelete
  2. Hello, You could use entityreference. I have done a new post. pls check the same.

    http://crmdm.blogspot.com/2011/06/how-to-retrieve-lookup-attribute-from.html

    ReplyDelete
  3. Hi Manjaly, thanks for posting this great but simple post. I would like to get another attributes value from lookup field base entity. let's say I have contact lookup field in my account form and I want to insert contact's address into address field in my account form when contact lookup is onchange. Can I use jscript to do that, do you have any sample? thanks in advance.

    ReplyDelete
  4. getting error at array
    cannot create a instance of abstract class or interface "system.array"

    ReplyDelete
  5. Hi,

    I was wondering if it was possible to go through each object in a lookup table and save them to an array?

    The purpose is that I want a lookup table to contain each customer account codes, when a user tries to create a new account it will compare against the account codes in the lookup to see if it already exists?

    Thanks

    ReplyDelete