REST services 101: Retrieving data

Today I was doing some maintenance work for a customer, running a CRM 2011 enviroment. I was excited as this was my chance to do some development within the CRM platform, a substantial different game than SharePoint development.

The change I had to implement was about implementing an indicator whether a customer was using products or not. A fairly simple job…

Within the form, I extended the form onload event with some addtional javascript that changed the appearance of a label if the customer was using products. Therefor I had to do a REST service call in order to get data.  This was becoming interesting…

Where do I had to get the data?

Which service do I need to use?

What are the internal names I have to use?

Within the section “Settings”, “Customization” there is a link “Developer Resources”. Clicking this link leads you to the Developer Resources page, containing some service endpoints. One of them is called “Organization Data Service”. Clicking the Organization Data Service link, gives you an extensive list containing the names of all datasets that can be retrieved using the Organization Data Service.

In this list I did a lookup of the entity I needed.

F2

I wrote down the title of the collection (case sensitive) I needed and proceeded.

Now I had to define the fields in my query, in order to do that I needed the schema names of the fields. The easiest way of doing that is to browse through the list of entities within the default solution. I found the entity I needed, and opened the Fields section in the list.

F3

The fields in the correct casing are presented in the “Schema Name” column.  I wrote down the fields I needed and moved on.

Finally I had to write the javascript functions to get the data from the rest service and display the indicator on screen.

F1

In the filter variable I specified the query using the entity name and the field names I found.

Another job done…

Leave a Reply

Your email address will not be published. Required fields are marked *