Eduardo
Eduardo

Reputation: 1831

Microsoft Dynamics API - Getting Fields from Entity with Navigation

I am trying to get the field list from an entity, in example contact, I have successfully done it doing a Request to:

EntityDefinitions(LogicalName='contact')/Attributes/Microsoft.Dynamics.CRM.AttributeMetadata

But now I need to get the Navigation Properties defined on this entity, I have found information on how to get Navigation Properties when querying a specific record by id, but in this case I need it when getting the field list.

Thanks in advance for your help

Upvotes: 1

Views: 1524

Answers (1)

Alex
Alex

Reputation: 23300

Referring the docs: https://learn.microsoft.com/en-us/powerapps/developer/data-platform/webapi/query-metadata-web-api

You already have the Lookup attributes, AttributeMetadata has everything. If you want to only read the metadata of lookups, change the type to LookupAttributeMetadata.

EntityDefinitions(LogicalName='contact')/Attributes/Microsoft.Dynamics.CRM.LookupAttributeMetadata

To obtain relationships info alongside the columns list then an additional query is required, RelationshipDefinitions:

/RelationshipDefinitions/Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata
/RelationshipDefinitions/Microsoft.Dynamics.CRM.ManyToManyRelationshipMetadata

filter on ReferencedEntity / ReferencingEntity to limit the results
/RelationshipDefinitions/Microsoft.Dynamics.CRM.ManyToManyRelationshipMetadata 

filter on Entity1LogicalName / Entity2LogicalName / IntersectEntityName

Upvotes: 2

Related Questions