After my previous post, I continued to explore virtual entities to see what real life problems I can solve using them. One problem I could think of was metadata. How awesome would it be, if I can use Advanced Find to query entity and attribute metadata, or visualise them as a normal entity! It is not a dream anymore. I have developed an open-source solution to do this.
Here is some of the sample queries:
Query all attributes of type customer
Query all mandatory attributes
Query by Attribute Type and Entity
Query all Many to Many intersect entities
Query entities that have quick create enabled
You can open the entity and see more details.
You can open the attribute and view more details as well.
All this is awesomeness is possible using the power of virtual entities. There are two virtual entities that you can query. They are called Entity and Attribute.
You can download the source code and managed solution from https://github.com/rajyraman/Metadata-Virtual-Entity/releases.
This step is important
After importing the managed solution, change the data source for the attribute entity from “Entity Datasource” to “Attribute Datasource”. You have to do this from the Customization area and not from the managed solution.
This is because by default, the system does not allow relationships between two virtual entities that have different datasources. This exception is shown when you try to do this.
In order to workaround this exception, you keep the data source same for the “Entity” virtual entity (parent) and “Attribute” (child) virtual entity, create the relationship and then change to the right datasource. Hence, the managed solution has the datasource set to “Entity Datasource” for the “Attribute” virtual entity, which has to be changed manually after importing the solution.
I hope this solution would be really useful for administrators. Please let me know any feedback on the post or on GitHub issues.
Managed Solution: https://github.com/rajyraman/Metadata-Virtual-Entity/releases/latest
Any idea why there is this limitation of related entities with different datasources? Obviously it can still be accomplished…
I am not sure. I emailed the dev today. Awaiting response.
Suppose you have a standard entity and created a lookup to a virtual entity. Now suppose you try to query that entity with a filter on an attribute from the lookup virtual entity. The system would convert the FetchXML into a SQL statement to execute against the CRM database, but it would fail because the virtual entity doesn’t exist as an actual table.
[…] Using virtual entities to query metadata […]