Using Microsoft Dynamics CRM API to get Status Reason Metadata Option

Introduction

Dynamics 365 is a metadata-driven application; sometimes, we need to query the system metadata on the client side to get the configuration of an organization. This can be achieved using the Dynamics 365 API and the organization service. The Web API allows us to query metadata but does not allow us to detect changes in metadata at any given time.

 

 

StatusCode With Dynamic CRM API

We will try to achieve the retrieval of the Status Code from the Dynamics API with a metadata call.

There are two types of options in metadata to retrieve option set from Dynamics API

  • Dynamics.CRM.PicklistAttributeMetadata is used for option sets
  • Dynamics.CRM.StatusAttributeMetadata is used for the status reasons

Microsoft.Dynamics.CRM.StatusAttributeMetadata API Example

Now, let us create the query for the retrieval of status code option values

Further Read: Dynamics CRM FetchXML with new Microsoft Dynamics CRM V9 API

Elevate your CRM Strategy with AlphaBOLD!

Ready to elevate your CRM strategy and leverage the full potential of Microsoft Dynamics CRM? Let AlphaBOLD guide you through the advanced analytics landscape to harness the power of your customer data.

Request a Demo
GET [Organization URI]/api/data/[Api version]/ EntityDefinitions(LogicalName=”Entity Logical Name “)/Attributes(LogicalName=”Attribute Logical Name “)/Microsoft.Dynamics.CRM. StatusAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)

Now, you can run this in the same browser where you are logged in to Dynamics CRM so we can verify the result. The result set would be like the one below.

this image show's retrieval of status code

JS Code:

We will create the XMLHttpRequest and then send the request with the call for metadata API functions. See the image below.

this image shows the JS function

So, we will be able to get the status code for the entity at the client side with the help of CRM  API using the code above.

Microsoft.Dynamics.CRM.PicklistAttributeMetadata API Example:

Now let us create the query for the retrieval of option set values.

GET [Organization URI]/api/data/[Api version]/ EntityDefinitions(LogicalName=”Entity Logical Name “)/Attributes(LogicalName=”Attribute Logical Name “)/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=GlobalOptionSet($select=Options)

Similarly, we will verify the query in the same browser where you are logged in to CRM so we can verify the result. The result set would be like the one below.

this image shows the verify the result

JS Code:

We will create the XMLHttpRequest and then send the request with the call for metadata API functions. See the images below.

this image shows the metadata API

Make Smarter Decisions with AlphaBOLD and Dynamics CRM!

AlphaBOLD is ready to assist you in navigating the complex world of CRM analytics. Start your journey toward enhanced data analytics and strategic insights with us.

Request a Demo

Similarly, using the code mentioned above, we can get the option set value for an entity.

Explore Dynamics 365 CRM Solutions

Conclusion

We can use the Dynamics 365 API function in JS to get the Status code and Option set values on the client side. If you have any questions or queries, please contact us

Explore Recent Blog Posts

Infographics show the 2021 MSUS Partner Award winner

Related Posts

Receive Updates on Youtube