Scenario 3
Andy is working on a solution in which he needs to populate the fields of an entity into an option set. He wants to load the option set dynamically. To retrieve the fields of a particular entity, you can query the metadata using the Web API. All the attributes of an entity can be retrieved using the metadata query. In this scenario, it is demonstrated how the attributes of a Contact
entity can be retrieved using a Web API call.
Retrieving metadata using the Web API
Microsoft Dynamics 365 is a metadata-driven application. Sometimes, you need to query the metadata while working with requirements such as those mentioned in this scenario. For this purpose, you can easily query the metadata using the Web API. We will use the EntityDefinitions
entity to retrieve the metadata of the Contact
entity. The URL will be as follows:
clientURL + "api/data/v8.2/EntityDefinitions(LogicalName='contact')/Attributes"
We will create an HTML web resource and the following is the code to retrieve the metadata...