locked
Filtering Entity Metadata in Dynamics CRM 2013 RRS feed

  • Question

  • Hi,

    I am using the "RetrieveAllEntitiesRequest" method of CRM 2013 metadata web service to get the list of Entities in Dynamics CRM. Now, whenever I execute the method something like this, I am getting a huge list of entities :

    RetrieveAllEntitiesRequest request = new RetrieveAllEntitiesRequest()
    {
    	EntityFilters = EntityFilters.All,
    	RetrieveAsIfPublished = true
    };
    RetrieveAllEntitiesResponse response = (RetrieveAllEntitiesResponse)orgService.Execute(request);

    What I want to do is retrieve only the entities that can actually be created, modified, deleted, have their state changed, etc. meaning basically all entities that we can interact with. The above code returns all the entities, even the internal ones like plugin steps, and internal stuff that CRM uses. I want to exclude these internal stuff.

    I tried with all types of EntityFilters like Entity, All, Attributes, Privileges, Relationships, etc. but I didn't find anything substantial like maybe a field "CanBeCreated" or "CanBeModified" etc. that says the entity is possible to be interacted with.

    Please could someone help me with this? I end up getting around 300 entities in Vanilla CRM even when I don't need them.


    Admin QuikView Solution for CRM 2013

    Friday, June 27, 2014 9:28 AM

Answers

  • Yes, it will only return those entity which is customization and you can't set this filter in request itself because there is no member to set this property, so you need to filter only after getting all list.


    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Anupam Bishui Friday, June 27, 2014 1:41 PM
    Friday, June 27, 2014 11:29 AM
    Moderator
  • IsCustomizable is the most general attribute that indicates if an entity is customizable. However, the metadata also contains more specific attributes if you need them - e.g. CanCreateAttributes, CanCreateForms

    Note that you can only filter on these after you've retrieved the metadata for all entities. The EntityFilters parameter controls how much metadata is returned for an entity, and not which entities are returned


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by Anupam Bishui Friday, June 27, 2014 1:41 PM
    Friday, June 27, 2014 11:58 AM
    Moderator
  • I don't think this is indicated by an attribute. I think you have to check if there is a 1-many relationship between your entity and the annotation entity

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by Anupam Bishui Friday, June 27, 2014 1:41 PM
    Friday, June 27, 2014 1:32 PM
    Moderator

All replies

  • I think you need to get all entity list and then filter them based on IsCustomizable property

    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Friday, June 27, 2014 10:15 AM
    Moderator
  • Hi Mahendar,

    I was thinking the same initially, but does "IsCustomizable" guarantee the conditions that I am looking for? Also, is it possible to set the filter criteria in the request itself before executing it so that the time required to fetch the list is reduced and I do not have to filter it after I get the response?


    Admin QuikView Solution for CRM 2013


    Friday, June 27, 2014 11:03 AM
  • Yes, it will only return those entity which is customization and you can't set this filter in request itself because there is no member to set this property, so you need to filter only after getting all list.


    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Anupam Bishui Friday, June 27, 2014 1:41 PM
    Friday, June 27, 2014 11:29 AM
    Moderator
  • IsCustomizable is the most general attribute that indicates if an entity is customizable. However, the metadata also contains more specific attributes if you need them - e.g. CanCreateAttributes, CanCreateForms

    Note that you can only filter on these after you've retrieved the metadata for all entities. The EntityFilters parameter controls how much metadata is returned for an entity, and not which entities are returned


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by Anupam Bishui Friday, June 27, 2014 1:41 PM
    Friday, June 27, 2014 11:58 AM
    Moderator
  • Hi Guys,

    Thanks a lot for your clarification. Just one more question that keeps bugging me is we can disable/enable "Notes" for an entity while creating it. Now is there any attribute in the metadata which tells whether I can associate notes with it or not?


    Admin QuikView Solution for CRM 2013

    Friday, June 27, 2014 12:37 PM
  • I don't think this is indicated by an attribute. I think you have to check if there is a 1-many relationship between your entity and the annotation entity

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Marked as answer by Anupam Bishui Friday, June 27, 2014 1:41 PM
    Friday, June 27, 2014 1:32 PM
    Moderator
  • Thanks a lot guys! Really appreciate your help! :)

    Admin QuikView Solution for CRM 2013

    Friday, June 27, 2014 1:40 PM