Skip to main content

Retrieving data from Dynamics CRM to CRM Portals using Javascript - MS Dynamics CRM

When we are working with Dynamic CRM portals, we often require access to some other data in CRM instance other than the current page context. For this case CRM does not provide a straight forward way to access data using WebAPI. But options are open to extend the functionality using Liquid Templates and ODATA for exposing the data from CRM instance to CRM Portal which allows us to retrieve and format the data.

Before we get started with this, below are few prerequisites to make sure you understand what we are going to deal with:

1. Liquid Template 
Liquid is an open-source template language integrated into Dynamics CRM as dotliquid. It can be used to add dynamic content in pages, and to create a wide variety of custom templates. It is easy to learn.

Limitations of Liquid: As Liquid is a template language, it runs on server side and executes only on page load. This limits the usage of liquid template as we do not have any established connection to the server all time (running as a service). The template code is stored in the web page and based on a request from client, the current page context/view model will be applied to the template which renders/executes the template and returns the response as a output html or an instance of javascript based on our implementation.

Below is the blog post explaining end to end implementation of retrieving CRM data in portal with an Use Case scenario.
Step by Step guide to retrieve CRM data in Portal using Liquid Template

2. Open Data Protocol Feeds (ODATA) 
CRM has capability to expose the data as oData feed for selected entities and using with external applications (in our case it is CRM portal) will have the real time data with an on-demand request. This overcomes the limitation of Liquid template language as it is executed on page load and on server side.

On CRM end, We need to create a View or use an existing View to expose over oData feed then we need to create a Portal Entity List for that specific view and enable the oData feed. At this point you should have your odata end point running for the specified enitity and to access that data on portal just use the odata path in url.. for example https://XXXX.microsoftcrmportals.com/_odata

Below is blog post specific to enabling OData on CRM entity and consuming the same in CRM Portal
Step By Step guide to retrieve data from CRM to Portal using OData Feed

Comments