Personalized Community is here!
Quickly customize your community to find the content you seek.
‘Better Together’ Integration forum available
We're launching a how-to forum where you can learn and engage about how Dynamics 365 integrates with other Power Platform products.
Read about Better Together forum
2020 Release Wave 2Discover the latest updates and new features to Dynamics 365 planned through March 2021.
Release overview guides and videos Release Plan | Preview 2020 Release Wave 2 TimelineWatch the 2020 Release Wave 1 virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
Recently I have seen in the community, there is a requirement to show/hide opportunity “Close as won” and “Close as lost” button based on user security role without writing any code. Ideally in this scenario we basically retrieve the user role name using web API and then based on that we return true/false to show/hide the button using ribbon workbench enable rule. But now days as you may know that most of the browser deprecated Synchronous call and reason why we are following some alternate options like here Andrew Butenko’s mentioned his blog, Thanks to Andrew for his blog and its really useful when you need to do an API call.
I thought why not we do this without writing code, is this possible? yes, it is possible without writing code, but for that we need to first be sure which access we will be used to show/hide button in the security role. There are two way we can do this .
You may be thinking why I have first chosen Miscellaneous privilege? Yes, because most of our non-System Admin Dynamics 365 user not using all the miscellaneous privilege and for them certain Miscellaneous access is useless unless they have System Administrator role. And using Entity Privilege Rule you need to depend on another entity access, in that case you need to create a dummy entity, or you need use some unused entity privilege for that. So, to avoid maintain additional entity, I have used here Miscellaneous privilege rules under display rules.
In my scenario my user assigned to “Sales Manager” security role and I don’t want that he will be able close opportunity as won. As I mentioned that for “Sales Manager” Security role is not a System Administrator and should not have most of miscellaneous privilege. So here you can see user does not have “Publish Duplicate Detection Rules”.
Now lets open Ribbon workbench with opportunity entity. To do that you must create a solution and then include opportunity entity over there. Now open the solution using ribbon workbench. Find the button and click on “Customize Button” and then again right click on the button and click on “Customize Command”.
Once you do that, you can see Display Rules for the button.
Right click to add Display Rule –
Now in the Add Step choose “MiscellaneousPrivilgeRule”.
Now here are the rule details which I have set –
I have set here “Duplicate Detection” privilege depth “Basic” which means user with minimum access “Basic” on duplicate detection can see the “Won” button.
Now associate rules to the command, and then publish.
Now user having access “Sales Manager” login into Dynamics 365 and open an opportunity see “Close as won” button is not showing.
Similarly, to bring back button for other user make sure you need to provide Miscellaneous privilege “Publish Duplicate Detection Rules” at least user level access to other security roles.
I don’t want to go here all the details about entity privilege rules here, as the name suggest that you can show hide button based on certain entity privilege depth and type. This is a very useful features in Dynamics 365. You just need to define one entity depending on the privilege type/depths you can show hide the button. For example, lets suppose you want to hide if user does not have any access on “new_tesentity”, you can do create following rule.
And finally, please note this is workaround, and you must choose Miscellaneous Privilege very carefully and don’t forget to give other user access so that other user not faced any issue. If you think that you are ready to maintain additional entity you can always go with create a new entity and use “EntityPrivilegeRule” under display rule.
Hope this useful for you!!
Business Applications communities