Redirecting User to Specific Page After Login to Dynamics 365 Portal

Requirement: Support user should be redirected to support page after login to Dynamics 365 portal instead of home page. But later they can navigate to home page.

Solution– In order to implement this requirement, here we need to implement two checks:
1. Check if user is a support user.
2. Check if he is navigating to home page for the first time after login.

To implement first requirement, we are going to use User object here to check if current user is part of the Portal Support User web roles, if you are new to web roles, please refer this KB for how to create web roles.

 {% if user.roles contains 'Portal Support User'%}

Now to implement second requirement, I don’t find any straight out of the box configuration to redirect user to specific page after every login. Off course they will be redirect to Profile page for the first time login. But we can implement a workaround by writing quick javascript code to implement this requirement. We can use sessionStorage here to hold a flag to validate it. session storage is specific tab or page, so once it is closed, value of the session storage removed automatically. So we are going to use Home web template and will be using following code on the Home template, so navigate to Portals-> Web Templates and open Home template
And use following code:

<script type="text/javascript">
            if(window.sessionStorage) {
                     window.location.href = "/support";

Our full code should look like below:

customer service
Save your changes now, now when user will login he will be automatically redirected to support page.
If you are not able to see changes, try to clear Portal Cache.

Leave a Reply