Tuesday 29 October 2019

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

No comments:

Post a Comment