Hello,
I have two pages one is a booking page and the other is a partner booking page. I require that for booking page it should be visible to both anonymous users and authenticated users. For the partner booking page, I have created a custom web role called the broker's role. The partner booking pages should only be visible to those users who have a broker's web role which is working fine.
However, the booking page should not be visible to users who have a broker's role which is not working.
I have tried using the web page access control rule but it is also working, the booking page is not getting hidden when users who have a broker's web role are logged in.
How can I achieve this?
Thanks
@RohitAswal You don't need javascript to hide weblinks - by configuring Page Access and assigning them to specific webroles you can achieve this by out-of-the-box functionality:
Set page permissions | Microsoft Learn
Hi @RohitAswal
Based on our understanding, it seems you're encountering an issue with hiding certain pages based on web roles. To address this, you can modify the visibility conditions in the header web template according to your specific requirements.
Below, I've provided an example of how to hide web links based on web roles. In this example, if the user has the "Broker" web role, then the first web link (booking page) is hidden:
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script
type="text/javascript">
var usersRol =
'{{user.roles}}';
console.log(usersRol);
if(usersRol.includes("brokers web roleAuthenticated Users")){
var containerr = $(".container")[0];
$($(containerr).find(".weblink")[1]).hide();// Change the value of [] according to your web link set
}
// Your existing code goes here
</script>
Create a web role Brokers
To reflect the change save and sync
Output:
1. Green highlighted for who user having web role brokers
2. Red highlighted are anonymous
3. Blue highlighted are for authenticated user
Thanks!
Inogic Professional Services
An expert technical extension for your techno-functional business needs
Power Platform/Dynamics 365 CRM
Drop an email at crm@inogic.com
Service: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
@Fubar , could you please show and share some screenshots of how it is done?
Thanks
Hi @Inogic ,
I have tried your method but I think it's not working. Here is the code that I have written
Hi Rohit,
Kindly try below link :
Thanks,
Akshay shah
Hi @RohitAswal ,
Based on our understanding, it seems you're encountering an issue with hiding certain pages based on web roles. To address this, you can modify the visibility conditions in the header web template according to your specific requirements.
Below, I've provided an example of how to hide web links based on web roles. In this example, if the user has the "Broker" web role, then the first web link (booking page) is hidden:
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script
type="text/javascript">
var usersRol =
'{{user.roles}}';
console.log(usersRol);
if(usersRol.includes("brokers web roleAuthenticated Users")){
var containerr = $(".container")[0];
$($(containerr).find(".weblink")[1]).hide();// Change the value of [] according to your web link set
}
// Your existing code goes here
</script>
Thanks!
Inogic Professional Services
An expert technical extension for your techno-functional business needs
Power Platform/Dynamics 365 CRM
Drop an email at crm@inogic.com
Service: http://www.inogic.com/services/
Power Platform/Dynamics 365 CRM Tips and Tricks: http://www.inogic.com/blog/
By default the Authenticated User Web Role is inherited by all logged in users (it does not need to be directly assigned to the user for them to get its privileges). What you will probably need is the Authenticated User without the access control rule, and two other Web Roles to hold each of the access control rules that you want to use to show/hide and directly assign/remove these roles when setting up the users.
(note: there is a checkbox on the Web Role that will stop this inheritance behavior, and if using inheritance only 1 Web Role can have each respective checkbox ticked as if there are multiple Web Roles with the same checked the system will choose only 1 of them to use).
Hi,@Akshay_Shah
I have configured power pages enhanced model
Hi Rohit,
You have configured Power pages or powerapps portal in the CRM?
Thanks,
Akshay shah
WarrenBelz
9
Most Valuable Professional
Rondel
6
oliver.rodrigues
4
Most Valuable Professional