Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Can we hide fields based on security roles? What is best way?

(0) ShareShare
ReportReport
Posted on by

We want to hide certain fields from appearing based on security role.  Is this possible?  I know with Field Security you can make fields read only but they still appear.

What is the best way to hide fields completely for certain users?

  • RE: Can we hide fields based on security roles? What is best way?

    Thank you.  I know business rules can do JS through configuration but I don't think you can make an option to hide via security role through there so would have to be JS

  • ACECORP Profile Picture
    ACECORP 1,579 on at
    RE: Can we hide fields based on security roles? What is best way?

    Yes, the field label will be present and visible. Depending on the specific Field Security setting you implement, the data inside the field will either be readable or hidden with *** characters.

  • RE: Can we hide fields based on security roles? What is best way?

    Thank you.  With field security the Field Label still would appear though right?

  • Suggested answer
    ACECORP Profile Picture
    ACECORP 1,579 on at
    RE: Can we hide fields based on security roles? What is best way?

    Yes, there are several ways to do that actually.

    1. One way, the out of box way, is to use Field Security Profiles to change users ability to read/write data to the field as well as hide the contents of the field based on Security Role. See: https://docs.microsoft.com/en-us/power-platform/admin/field-level-security
    2. The second way is to use JavaScript to "check" if the user has a certain security role assigned to them, and if they do, you can make a lot of different UI changes using JavaScript. This is in the realm of custom development, but it opens up the UI to a lot of different capabilities based on if the user is a member of a specific security role or not. 

    An example of how to implement a JavaScript check for security roles, and action the UI based on the result is shown below. 

    function UIActionBasedOnSecurityRole() {
        var roles = [];
        roles[0] = "Insert_Desired_Security_Role_Name_Here";
        var IsUserMemberOfRDR = currentUserHasSecurityRole(roles);
    
        function currentUserHasSecurityRole(roles) {
            var fetchXml = ""   ""   ""   ""   ""   ""   ""   ""   "";
    
            for (var i = 0; i < roles.length; i  ) {
                fetchXml  = "";
            }
    
            fetchXml  = "            "   ""   ""   ""   "";
            var modifiedFetchXml = fetchXml.replace("&", "&");
            var users = ExecuteFetch(modifiedFetchXml, "systemusers");
            if (users > 0) return true;
            else return false;
        }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,703 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans