We will learn to retrieve entity / table metadata in Power Apps / Dynamics 365 using SDK for .NET. Before we start, make sure you subscribe to CRM Crate so that you can stay up to date in the field of Power Platform.
Tables or entities are used for the representation and administration of business data. When creating an application, one has the option to utilize standard tables, custom tables, or a combination of both. Microsoft Dataverse inherently includes standard tables that are crafted following best practices to effectively capture prevalent concepts and scenarios within an organization. A table defines information that you want to track in the form of rows such as name, email, phone number etc.
Below are the different types of tables in Power Apps:
- Standard Table: Within a Power Platform environment, which incorporates Microsoft Dataverse, a variety of standard tables, referred to as out-of-box tables, are pre-included. Examples of these standard tables in Dataverse include Account, Business Unit, Contact, Task, and User tables. The majority of the standard tables provided by Dataverse can be tailored to suit specific needs. Additionally, tables imported as part of a managed solution and marked as customizable will also be recognized as standard tables.
- Virtual Table: These tables are used when you need to populate them with the data from an external source outside of Dataverse.
- Activity Table: Representing a unique table category, activity tables are used for accommodating rows with activity-centric attributes, encompassing elements like subject, start time, stop time, due date, and duration. Dataverse is already equipped with various pre-configured activity tables, including but not limited to appointment, task, email, and phone call.
- Elastic Table: These tables are used when the table will store a very large dataset in excess of tens of millions of rows.
Using RetrieveAllEntitiesRequest to retrieve table metadata in Power Apps.
Utilizing the RetrieveAllEntitiesRequest to retrieve all entity / table metadata in Power Apps is a robust tool, empowering you to design customizations, integrate seamlessly with other systems, generate reports, validate data, and business specific console applications.
The below code demonstrates the utilization of RetrieveAllEntitiesRequest to fetch all tables / entities for the given environment in Power Apps.
var request = new RetrieveAllEntitiesRequest { EntityFilters = EntityFilters.All }; var response = (RetrieveAllEntitiesResponse)service.Execute(request); var tables = response.EntityMetadata.OrderBy(x => x.LogicalName).ToList(); tables.ForEach(table => { Console.WriteLine($"CRM Crate Entity Logical Name: {table.LogicalName}"); });
Below is the response outcome of RetrieveAllEntitiesResponse :
Below is the output of the above .NET code: