New Metadata Query features in Web API in Dynamics 365

Dynamics 365 is in and just like me, CRM enthusiasts all over the world are simply WOW’ed by its wonderful offerings. After all, this has been a giant leap by Microsoft and indeed a great opportunity for all consultants to me to plunge into unknown territories and conquer it.

In this blog post, I will walk you through the new Metadata Query features that has been introduced with Dynamics 365 Web API. Off late I have been developing some tools using were using the WEB API endpoint and these new additions to the WEB API will really help developers to query the metadata in a very simple way. So without wasting more time, let me straight way give you a flavor of this.

With Dynamics 365, the Web API endpoint has been upgraded to v8.2. So it would be typically in this format – /api/data/v8.2/">https://<organizationUrl>/api/data/v8.2/

For my trial organization, below is the screenshot.

image

Now comes the interesting part which is querying the metadata.

Below are some of the scenarios I explored and it works like a charm. I will show all the examples here related to the “contact” entity for my organization. The best thing that you find in the below examples is, using the Web API you can query the same way you do in organization service for your CRM Metadata.

 

Query Entity Metadata

https://xrmtr30.api.crm.dynamics.com/api/data/v8.2/EntityDefinitions(LogicalName=’contact’)

Isn’t it great! You can query the entity metadata using the EntityLogicalName just like you do in Organization Service.

And below is the JSON result I get which you just need to parse to get your data back.

image

 

Query Entity Metadata along with all attributes

https://xrmtr30.api.crm.dynamics.com/api/data/v8.2/EntityDefinitions(LogicalName=’contact’)/Attributes

And below is the sample JSON response for the field ‘First Name’

image

 

Querying single Field Metadata

So how about you want to query just a single field metadata. Well dynamics 365 is not here to disappoint you Smile

In the below query, I have just queried for the firstname metadata for the contact entity.

https://xrmtr30.api.crm.dynamics.com/api/data/v8.2/EntityDefinitions(LogicalName=’contact’)/Attributes(LogicalName=’firstname’)

And below is the JSON response.

image

 

Querying global Optionsets

Enough of querying fields specific to entity. How about global optionset? And yet again Dynamics 365 has your back.

https://xrmtr30.api.crm.dynamics.com/api/data/v8.2/GlobalOptionSetDefinitions(Name=’decisionmaker’)

In the above example, I am querying for the metadata of a global optionset called ‘decisionmaker’. And below is the sample JSON response.

image

 

Querying Relationships

The below query will query for the N:N relationship between contact and leads

https://xrmtr30.api.crm.dynamics.com/api/data/v8.2/RelationshipDefinitions(SchemaName=’contactleads_association’)

And below is the JSON response for the same

image

 

I am still exploring the wonderful features of Dynamics 365 and stay tuned for another interesting update.

 

Debajit Dutta

(Visit http://www.xrmforyou.com/products.html and checkout our tools library)

Advertisements

About Debajit
I am a Dynamics CRM Most Valuable Professional (MVP) with 10 years of experience in Microsoft .NET Technologies and 7 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

One Response to New Metadata Query features in Web API in Dynamics 365

  1. Nishant Rana says:

    Reblogged this on Nishant Rana's Weblog and commented:
    Metadata API improvements in Dynamic 365

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: