"тнιѕ вℓσ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;

        }

  }

10 comments:

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

    ReplyDelete
    Replies
    1. Hi Sushma, You can use this,
      https://santoshmscrm.wordpress.com/2015/06/22/how-to-retrieve-lookup-name-and-id-through-plugin/

      Delete
  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
  6. Can any one tell me how i can autopopulate the value of a lookup depending upon the value of another lookup. For example, I have two lookups, country and state. If I select a country, then the value of state must autopopulate only if there is one state associated with the country. If there are more than one states associated then it need not autopulate.

    ReplyDelete
  7. Hi, Not sure which version you are trying. These 2 posts are related to CRM 2011. Please take a look - http://crmdm.blogspot.com/2011/04/lookup-fitering-feature-in-crm-2011-or.html and http://crmdm.blogspot.com/2011/05/lookup-filtering-in-crm-2011-using.html

    ReplyDelete
  8. thanks, please help me.
    i have crm2011 the example runing pefect.

    var lookuptextvalue = lookUpObjectValue[0].name;


    i like return other field.

    var lookuptextvalue = lookUpObjectValue[0].new_namecustom; not return data.

    i need create lookup(oportunitid,namereturnfieldcustom)

    i have fiel enty custom field search type.
    i select oportuni
    i like saveform the field fill other field enty oportunid my field new_namecustom

    ReplyDelete