Thursday, 31 October 2019

Hide links from Primary Navigation in Dynamics 365 Portals

Hi,

Many times, we get the requirement to hide the links in the Primary Navigation of the Portal to the anonymous users.

To get this done, we have to create Web Page Control Rule

Navigate to Portals -> Web Page Access Control Rules -> New

Give the name and select the Website and WebPage that has to hidden.
Right - Select Restrict Read and Save the record.
After saving, go to Web Roles tab and add Authenticated Users web role to it.

Authenticated User
Anonymous User


Hope this helps.

--
Happy 365'ing
Gopinath

Tuesday, 29 October 2019

Add a custom button on Web Page - Dynamics 365 CE Portals

Hi,

Today when I was working on Portals, I got a requirement to add a cancel button beside Submit button on EntityForm and user has to navigate back to EntityList when click on it.

We can quickly do this by adding some script on the WebPage. Open the required WebPage and there is a tab named as Advanced and add the below code. I have used SiteMarkers to navigate. 


$(document).ready(function () {
    $('#InsertButton').after('<button id="cancelbutton" type="button" class="btn btn-primary button" style="margin-left:10px;"><span></span>Cancel</button>');
    $("#cancelbutton").click(function () {
        window.location.href = "{{ sitemarkers['ML_CustomEntityList'].url }}";
    });

});

Make sure you add the same piece of code in all Content Pages. 

Hope this helps.

--
Happy 365'ing
Gopinath

What are Site Markers in Dynamics 365 CE Portal?

Hi,

I was searching something on Portals and reached on Site Markers. Some how I felt that Site Markers are not used much in the Development of Portals. 

Many times we get a requirement to navigate to multiple places on click of buttons and we use Window.location and use the direct URLs or may be we some hyperlinks on Portal and we directly give the URL of the Web Page which works good until someone changes the Partial URL on the Web Page.

Site Markers are something which are designed for this. We have to create Site Markers and link the Web Page that is need and use Site Marker Name in the code to navigate. Here is the syntax for the same.

{ { sitemarkers["SitemarkerName"].url } }

Changing the name of the Sitemarker is strictly prohibited. This way, we don't face any issues even if the Partial URL on Web Page has changed. 

Hope this helps.

--
Happy 365'ing
Gopinath

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