locked
RETRIEVE ENTITY ATTRIBUTE VALUES BY SPECIFYING METADATA RRS feed

Answers

  • Hi,

    What I understand you want to fetch account data based on one attribute for example

    Fetch all accounts where account number =1

    you can use retrieve multiple function for that

    http://msdn.microsoft.com/en-us/library/bb929002.aspx

    Let me know if I did not understand your question correctly


    Mahain
    • Marked as answer by Hari nvp Friday, December 2, 2011 6:24 AM
    Friday, July 16, 2010 5:03 AM
    Moderator

All replies

  • Hi,

     

    I understand that you want to get the value of a particular field in the account enity. Am I right? If so, the simplest way could be to use the QueryByAttribute method of the CRM Service (not the metadata service), specify the attribute which value you want to get and execute it as described in the sample here: http://msdn.microsoft.com/en-us/library/aa685880.aspx .

    You may also build a query expression to get more values as described here: http://msdn.microsoft.com/en-us/library/bb928438.aspx

    I hope that helps,

    Jakub Skalbania


    -- Kuba Skałbania, Netwise
    Wednesday, July 14, 2010 2:39 PM
  • Thank u very much jakub,

                                            I actually want names of all the attributes of account entity...After that when I specifies one attribute name..(for eg:account number), I want to retrieve all  existing account numbers..Now, I think my doubt is clear to you.. how I can use QueryByAttribute method of the CRM Servicefor my purpose..help me pls

    Thursday, July 15, 2010 6:17 PM
  • Hi,

    What I understand you want to fetch account data based on one attribute for example

    Fetch all accounts where account number =1

    you can use retrieve multiple function for that

    http://msdn.microsoft.com/en-us/library/bb929002.aspx

    Let me know if I did not understand your question correctly


    Mahain
    • Marked as answer by Hari nvp Friday, December 2, 2011 6:24 AM
    Friday, July 16, 2010 5:03 AM
    Moderator
  • Hi,

    I think you want to retrieve the entity attributes: Below is the code which return the Entity Metadata:

    private RetrieveEntityResponse RetrieveEntityMetadata(string strEntityName)
                {
                    CrmAuthenticationToken token = new CrmAuthenticationToken();
                    token.OrganizationName = this._organization;
                    MetadataService service = new MetadataService();
                    service.CrmAuthenticationTokenValue = token;
                    service.Credentials = new NetworkCredential(this._userName, this._password, this._domain);
                    service.Url = "http://" + this._hostName + "/MSCRMServices/2007/MetadataService.asmx";
                    RetrieveEntityRequest request = new RetrieveEntityRequest();
                    request.EntityItems = EntityItems.All;
                    request.LogicalName = strEntityName.ToLower();  //this._entityName.ToLower();
                    return (service.Execute(request) as RetrieveEntityResponse);
                }

    Call the above fucntion as below:

    foreach (AttributeMetadata metadata2 in RetrieveEntityMetadata(strEntityName).EntityMetadata.Attributes)
    {
         // will display the attribute name: Perform the operations depending on the attribute name by using CASE statement
         string logicalName = metadata2.LogicalName;
    }

    Hope this will help you to resolve the issue.

     


    Thanks, Ranjitsingh R | http://mscrm-developer.blogspot.com/ | MS CRM Consultant
    • Proposed as answer by Ranjitsingh R Wednesday, August 4, 2010 8:19 AM
    Friday, July 16, 2010 5:33 AM