Is it possible to get all relationships available for an entity from CRM using the web api?
I have a requirement to get and show all available entity relationships in an HTML page separately. For example: if I selected "Account" on the html page, I should be able to see the 1: N, N: 1 and N: N relationships of the Account object.
I have tried below queries and I feel like it is not helping me correctly. Please suggest me a workaround for this.
https://<CRMORGNAME>/api/data/v8.2/RelationshipDefinitions/Microsoft.Dynamics.CRM.ManyToOneRelationshipMetadata?$select=Entity1LogicalName,SchemaName&$filter=Entity1LogicalName eq 'account'
https://<CRMORGNAME>/api/data/v8.2/RelationshipDefinitions?$select=RelationshipType,SchemaName
+3
source to share
1 answer
You can do it like this:
One for many:
https://contoso.crm.dynamics.com/api/data/v8.2/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/OneToManyRelationships?$select=SchemaName,RelationshipType
Many to one:
https://contoso.crm.dynamics.com/api/data/v8.2/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/ManyToOneRelationships?$select=SchemaName,RelationshipType
Many for many:
https://contoso.crm.dynamics.com/api/data/v8.2/EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/ManyToManyRelationships?$select=SchemaName,RelationshipType
Of course, you must first get the correct EntityDefinition (in this case for account "70816501-edb9-4740-a16c-6a5efbc05d84")
https://contoso.crm.dynamics.com/api/data/v8.2/EntityDefinitions?$select=SchemaName,LogicalName,MetadataId&$filter=LogicalName eq 'account'
+4
source to share