Hello folks, Sometime in D365 portal, we have the requirement to hide web page after login mean web page can access only by the anonymous user and after login the portal, web page is not visible to the user.
As you can see in below snapshot, Before login, page is visible
but after login page is not visible.
This kind of requirement can be achieved through code using js. Here i am assuming you have created your web page in the portal.
Now follow the below steps to achieve this requirement.
Step 1: Go to Portal > Web Template in CRM. Open Header Web Template.
Step 2: Copy the below code and change the name of a web page which you want to hide
Step 3: Paste this code at the end of Header Web Template code.
Now check your portal. It's working.
Hope this article helps you!
If you want to hide page for the anonymous user and visible for an authenticated user then Click Here to know that.
As you can see in below snapshot, Before login, page is visible
but after login page is not visible.
This kind of requirement can be achieved through code using js. Here i am assuming you have created your web page in the portal.
Now follow the below steps to achieve this requirement.
Step 1: Go to Portal > Web Template in CRM. Open Header Web Template.
Step 2: Copy the below code and change the name of a web page which you want to hide
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
var userEmail = '{{user.emailaddress1}}' ;
// Here my web page name is Register.
if (userEmail)
{
$('a:contains("NAME_OF_WEB_PAGE")').parent().next().hide();
$('a:contains("NAME_OF_WEB_PAGE")').hide();
}
else
{
$('a:contains("NAME_OF_WEB_PAGE")').parent().next().show();
$('a:contains("NAME_OF_WEB_PAGE")').show();
}
</script>
<script type="text/javascript">
var userEmail = '{{user.emailaddress1}}' ;
// Here my web page name is Register.
if (userEmail)
{
$('a:contains("NAME_OF_WEB_PAGE")').parent().next().hide();
$('a:contains("NAME_OF_WEB_PAGE")').hide();
}
else
{
$('a:contains("NAME_OF_WEB_PAGE")').parent().next().show();
$('a:contains("NAME_OF_WEB_PAGE")').show();
}
</script>
Step 3: Paste this code at the end of Header Web Template code.
Now check your portal. It's working.
Hope this article helps you!
If you want to hide page for the anonymous user and visible for an authenticated user then Click Here to know that.