Retrieve Dynamics 365 CE data in Portal by using Odata Feed using JavaScript

Hi,

Today I have some requirement to get some data from CE and show it on the UI. We can do it very easily by doing a OData call. 

Here are the steps to be followed for the same. 

1) Create an EntityList with the required entity. Make sure you select the view, Enable Entity Permissions (if you uncheck this, you will see 500 Error as you don’t have the permission to view the data).

2) Navigate to OData Feed tab and enable it. EntityTypeName and EntitySetName are textboxes, you can give as per your wish and then select the view.

3) Hit the browser with your portal URL and “/_odata”
   https://abc.microsoftportals/_odata

4) You will see the list of entities on which Odata feed is enabled.

5) Now you can hit browser with the name that was given and you can see the results. https://abc.microsoftportals/_odata/ContactSet

In case if you are not seeing the results, please check Entity Permissions and give the right permissions.

6) You can use below code by passing OdataURL and it will get the results for you.

function getResponse(oDataUrl) {
    var response = null;
    $.ajax({
        type: “GET”,
        url: oDataUrl,
        dataType: “json”,
        async: false
    }).done(function (json) {
        response = json.value;
    });
    return response;
}


Hope this helps.


Happy 365’ing.

Gopinath

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s