locked
how to retrieve contact fileds using plugin ? RRS feed

  • Question

  • Hi ,

    can any one tell me how to retrieve firstname, last name , midle name and email of a contact record using plugin ?

    Monday, February 28, 2011 8:36 AM

Answers

  • Hi Rao,

     

    you can retrieve using the following code snippet.

     

    Guid id=((Lookup)entity.Properties["accountid"]).value;

    String Name=((Lookup)entity.Properties["accountid"]).name;

     

    Regards,

    Vinoth

    Thursday, March 3, 2011 6:42 AM

All replies

  • Hello Raov1,

    Use the following code snippet:

     

    if (myEntity.Properties.Contains("your_field_schema_name"))
       string value = myEntity.Properties["your_field_schema_name"].ToString();
    
    // and replace your_field_schema_name with <strong><em>firstname, middlename, lastname and emailaddress1</em></strong>
    
    For a complete example, please read this post: http://social.microsoft.com/Forums/en/crm/thread/ff196045-8ce1-4224-bc36-60096454d174.

     

     


    Cornel Croitoriu - Senior Software Developer & Entrepreneur

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    CWS SoftwareBiz-Forward.comCroitoriu.NET

    • Proposed as answer by Khadim Ali Monday, February 28, 2011 10:54 AM
    Monday, February 28, 2011 9:18 AM
  • hi ,

     

    how to retrive lookup data in plugin ?

    please tell me about this.

    say in lookup i have data "ABC",

    i want to read this and save to one text filed.

    thnaks

    Thursday, March 3, 2011 5:58 AM
  • hi cornel,

     

    thnaks

    can you please tell me how to read lookup data .

    thanks

    Thursday, March 3, 2011 6:10 AM
  • Hi Rao,

     

    you can retrieve using the following code snippet.

     

    Guid id=((Lookup)entity.Properties["accountid"]).value;

    String Name=((Lookup)entity.Properties["accountid"]).name;

     

    Regards,

    Vinoth

    Thursday, March 3, 2011 6:42 AM
  • Hi Rao,

     

    you can retrieve using the following code snippet.

     

    Guid id=((Lookup)entity.Properties["accountid"]).value;

    String Name=((Lookup)entity.Properties["accountid"]).name;

     

    Regards,

    Vinoth

    • Proposed as answer by Vnothkumar Thursday, March 3, 2011 6:44 AM
    Thursday, March 3, 2011 6:43 AM
  • You mean you want to save in other field of same record.

    If it is the same record and then I would recommend using Javascript to get values rather than Plugin.

     

    For Plugin:

    You need to first register the plugin for specific event

    If you change the Lookup on form then you will get lookup values in InputParameter. If you don't change the value then you need to register Post Image to get lookup values.

    Refer this link

    http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/0f880952-cf8a-4ee4-b05b-2555094198ff

     


    Jai Ho CRM http://mscrmkb.blogspot.com Skype - amol.gholap

    Mark as answer if a post has answered the question
    Thursday, March 3, 2011 8:23 AM
  • hi vinoth,

    i am getting null value.

     

    thanks

    Thursday, March 3, 2011 9:19 AM
  • hi,

    i want to read this using plugin, because i am reading other fileds also, and problem with only the lookup value.

    can you please tell me how to read this.

     

    thanks

     

     

    Thursday, March 3, 2011 9:20 AM
  • In some cases, the name of the Lookup is not provided in the lookup property.
    You have to handle this since name is not a required property to assign when creating a lookup object.

    If you need the name of the lookup, first try getting the lookup.name property - if it's null or "" -> Retrieve the primary attribute value (text) from the referenced record in the lookup.

    /Emil

    Thursday, March 3, 2011 9:24 AM
  • Hi Rao,

    can u explain further abt how u registered the plugin.

    Regards,

    Vinoth

    Thursday, March 3, 2011 9:41 AM
  • hi vinoth,

     

    in the plugin i am retrieving the following fields of " contact "entity.

    1. first name

    2. last name

    3. address1(street1)

    4.Country( this is lookup) of the entity country. here countrylookup id is "hg_contact-countryid" and the country id is hg_countryid.

    so i want to read this. from the exsting contact record.

    i used pre stage, asynchronous plugin registratiopon

    so please telle me how to read the country of the partuicular record.

    Thursday, March 3, 2011 9:48 AM
  • Hi Rao,

     

    U cant use Pre stage in async.

     

    Regards,

    Vinoth

    Thursday, March 3, 2011 10:00 AM
  • sorry, i am using synchronous only.
    Thursday, March 3, 2011 10:08 AM
  • Hi Rao,

    try to debug the plugin.

    if its not coming then write a separate query to retrieve the name.

     

    Regards,

    Vinoth

    Thursday, March 3, 2011 10:17 AM
  • Hi Rao,

    Can U share the Code Here.

     

    Regards,

    Vinoth.

    Thursday, March 3, 2011 10:18 AM