locked
CRM 2011 Entity metadata RRS feed

  • Question

  • Hello,

    How can I find the selected entity is custom or customizable using entity metada in Plugin code? Please let me know.

    Thank you.

     

    Monday, July 25, 2011 7:06 PM

Answers

  • You need to examine the properties of the response like this:
    
     RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
      {
      EntityFilters = EntityFilters.All,
      LogicalName = "account"
      };
      RetrieveEntityResponse retrieveBankAccountEntityResponse = (RetrieveEntityResponse)service.Execute(retrieveBankAccountEntityRequest);
    
      bool test = retrieveBankAccountEntityResponse.EntityMetadata.IsCustomizable.Value;
      bool test2 = retrieveBankAccountEntityResponse.EntityMetadata.IsCustomEntity.Value;
    



    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!

    • Proposed as answer by Jamie MileyModerator Monday, July 25, 2011 8:14 PM
    • Marked as answer by anate Monday, July 25, 2011 9:13 PM
    Monday, July 25, 2011 8:13 PM
    Moderator
  • Hi,

    As Jammie mentioned that you can get the status using RetrieveEntityRequest, i wrote the full code to make it easy for you to check whether entity is custom or customizable

     

    RetrieveEntityRequest jj_RetrieveEntityRequest = new RetrieveEntityRequest();
    
    RetrieveEntityResponse jj_RetrieveEntityResponse = null;
    
    bool jj_IsCustomEntity = false, jj_IsCustomizableEntity = false;
    
    jj_RetrieveEntityRequest.EntityFilters = Microsoft.Xrm.Sdk.Metadata.EntityFilters.Entity;
    
    jj_RetrieveEntityRequest.LogicalName = "gits_application";
    
    jj_RetrieveEntityResponse = (RetrieveEntityResponse)crmService.Execute(jj_RetrieveEntityRequest);
    
    if (jj_RetrieveEntityResponse != null)
    {
     jj_IsCustomEntity = jj_RetrieveEntityResponse.EntityMetadata.IsCustomEntity.HasValue;
      
     jj_IsCustomizableEntity = jj_RetrieveEntityResponse.EntityMetadata.IsCustomizable.Value;
    }
    

     


    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".

    • Proposed as answer by Jehanzeb.Javeed Monday, July 25, 2011 8:28 PM
    • Marked as answer by anate Monday, July 25, 2011 9:11 PM
    Monday, July 25, 2011 8:23 PM

All replies

  • Monday, July 25, 2011 7:32 PM
    Moderator
  • I need to find if the entity is Custom or Customizable. I don't see any example in the link you provided.
    Monday, July 25, 2011 7:55 PM
  • You need to examine the properties of the response like this:
    
     RetrieveEntityRequest retrieveBankAccountEntityRequest = new RetrieveEntityRequest
      {
      EntityFilters = EntityFilters.All,
      LogicalName = "account"
      };
      RetrieveEntityResponse retrieveBankAccountEntityResponse = (RetrieveEntityResponse)service.Execute(retrieveBankAccountEntityRequest);
    
      bool test = retrieveBankAccountEntityResponse.EntityMetadata.IsCustomizable.Value;
      bool test2 = retrieveBankAccountEntityResponse.EntityMetadata.IsCustomEntity.Value;
    



    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!

    • Proposed as answer by Jamie MileyModerator Monday, July 25, 2011 8:14 PM
    • Marked as answer by anate Monday, July 25, 2011 9:13 PM
    Monday, July 25, 2011 8:13 PM
    Moderator
  • Hi,

    As Jammie mentioned that you can get the status using RetrieveEntityRequest, i wrote the full code to make it easy for you to check whether entity is custom or customizable

     

    RetrieveEntityRequest jj_RetrieveEntityRequest = new RetrieveEntityRequest();
    
    RetrieveEntityResponse jj_RetrieveEntityResponse = null;
    
    bool jj_IsCustomEntity = false, jj_IsCustomizableEntity = false;
    
    jj_RetrieveEntityRequest.EntityFilters = Microsoft.Xrm.Sdk.Metadata.EntityFilters.Entity;
    
    jj_RetrieveEntityRequest.LogicalName = "gits_application";
    
    jj_RetrieveEntityResponse = (RetrieveEntityResponse)crmService.Execute(jj_RetrieveEntityRequest);
    
    if (jj_RetrieveEntityResponse != null)
    {
     jj_IsCustomEntity = jj_RetrieveEntityResponse.EntityMetadata.IsCustomEntity.HasValue;
      
     jj_IsCustomizableEntity = jj_RetrieveEntityResponse.EntityMetadata.IsCustomizable.Value;
    }
    

     


    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".

    • Proposed as answer by Jehanzeb.Javeed Monday, July 25, 2011 8:28 PM
    • Marked as answer by anate Monday, July 25, 2011 9:11 PM
    Monday, July 25, 2011 8:23 PM