locked
How to Retrieve All attributes of an Entity RRS feed

  • Question

  • I am using MS CRM Online 2011 and IOrganizationService and am trying to retrieve all attributes for an Entity and am unable to find any Metadata API/Message.

    I have tried many but none seem to return all the attributes but unable to find it to return it. I see some code that uses ColumnSet(true) and retrieves a record and then gets its attribute. In our case we do not know a Guid to request and so would not work.

    RetrieveAllEntity message is not returnning all Attributes as I find it always null.

    My project requires Java, but an C# example can also be helpful.

    Any suggestions / samples to retrieve all attributes for a given object would be very much appreciated.

    Thanks

    Rajeev

    Sunday, July 17, 2011 1:09 PM

Answers

  • Hi,

    Try like this:

        RetrieveEntityRequest lclAEntityMetaDataRequest = new RetrieveEntityRequest();
    
        RetrieveEntityResponse lclEntityMetaDataResponse = null;
    
        lclAEntityMetaDataRequest.EntityFilters = Microsoft.Xrm.Sdk.Metadata.EntityFilters.Attributes;
        
    
        lclAEntityMetaDataRequest.LogicalName = "account";
    
        lclEntityMetaDataResponse = (RetrieveEntityResponse)lclCrmService.Execute(lclAEntityMetaDataRequest);
    
        //lclEntityMetaDataResponse.EntityMetadata.Attributes
    


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Sunday, July 17, 2011 2:26 PM

All replies

  • Hi,

    Try like this:

        RetrieveEntityRequest lclAEntityMetaDataRequest = new RetrieveEntityRequest();
    
        RetrieveEntityResponse lclEntityMetaDataResponse = null;
    
        lclAEntityMetaDataRequest.EntityFilters = Microsoft.Xrm.Sdk.Metadata.EntityFilters.Attributes;
        
    
        lclAEntityMetaDataRequest.LogicalName = "account";
    
        lclEntityMetaDataResponse = (RetrieveEntityResponse)lclCrmService.Execute(lclAEntityMetaDataRequest);
    
        //lclEntityMetaDataResponse.EntityMetadata.Attributes
    


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Sunday, July 17, 2011 2:26 PM
  • The ColumnSet option is when you retrieve a record (or a collection of records) you can speciofy which attributes to retrieve (or all if you instantiate as new ColumnSet(true)).

    If you are talking about retrieving the AttributeMetadata for all the attributes in an EntityMetadata then you must use the EntityFilters as shown by Jehanzeb


    Gonzalo | gonzaloruizcrm.blogspot.com

    Sunday, July 17, 2011 8:10 PM
    Moderator