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

Saturday 11 June 2011

How to retrieve a lookup attribute from Plugin in CRM 2011

Related Post : http://crmdm.blogspot.com/2011/03/how-to-retrieve-lookup-text-value-id.html


In CRM 2011 we could use EntityReference to retrieve the lookup attribute from a Plugin.



Consider that we have a Contact lookup named as 'new_contact'. In the plugin we could use the following code to retrieve the lookup.

Code snippets:

CRM 2011:
EntityReference
contactlookup = (EntityReference)targetEntity.Attributes["new_contact"];



CRM 4:

Lookup contactlookup = (Lookup)targetEntity["new_contact"];

8 comments:

  1. Hi,
    I need to retrieve a checkbox attribute.
    Any idea how I can do it?
    And which function should I use to trigger that action because Retrieve function is not working.
    Thank you

    ReplyDelete
  2. hello, Are you trying this from javascript or plugin ?

    From Javascript :http://crmdm.blogspot.com/2011/03/how-to-retrieve-checkbox-value-in-crm.html
    Also pls refer the following...http://crmdm.blogspot.com/2011/03/checkbox-onchange-event-is-not-working.html

    ReplyDelete
  3. Hi again,
    I'm trying to get the lookup value, I got the ID but I wasn't able to get the text value.
    I used contactLookup.Name.toString(), it's returning null.
    How to do that?
    Thank you

    ReplyDelete
  4. You could try this
    http://crmdm.blogspot.com/2011/03/how-to-retrieve-lookup-text-value-id.html

    ReplyDelete
  5. The other one is Jscript.
    Can you continue the code on ow to get the text value?
    Would appreciate that

    ReplyDelete
  6. Sorry i thought you were trying in js. That's very strange.So you got ID but not name. How about logical name?. Do you have any value in that?

    ReplyDelete
  7. Great Post

    Thanks for sharing

    ReplyDelete
  8. The result retrieved shows as:
    Microsoft.Xrm.Sdk.EntityReference

    How can i get the value of the lookup?

    ReplyDelete