web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

disabling button x++

(0) ShareShare
ReportReport
Posted on by 244
Hi,

We are asked to disable a certain button for two specific roles
Role1
Role2


This button is a menu item on a form. (it performs an action)
This menu item is added to a privilege. And this privilegecontains other menu items with it.
The privilege has delete access

And this privilege exists on two duties
Duty1
Duty2

Duty1 is added to 4 roles
RoleX
RoleY
RoleZ
RoleQ

Duty2 is added to 4 roles
RoleA
RoleB
RoleC
RoleD

So Role1 and Role2 don't have this privilege in the first place.
However, the enable and disable is handled by code
so there is code that says if condition1&condition2&condition3 then enable or disable the button -- which means it doesn't look at privileges.

So it correct to handle the requirement like this?
so if the below method returns true then it means disable (of course we'll take into account original conditions as well)

Categories:
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,866 Most Valuable Professional on at
    No, it's not the recommended approach. You should configure permissions as you need instead of writing code trying to do what the standard logic should cover.
  • CU22120935-0 Profile Picture
    244 on at
    Hi @Martin Dráb,

    So what to do in this case? I didn't understand
  • Martin Dráb Profile Picture
    239,866 Most Valuable Professional on at
    You said you wanted Role1 and Role2 not to have access to the button and that they indeed didnn't have the permission, therefore your goal seems to be already achieved. No code is needed and the current code violates your requirements, therefore you should remove it. 
     
    Or your actual problem is different and you'll need to give a better description of it.
  • CU22120935-0 Profile Picture
    244 on at
    Hi Martin,

    There is code on the form that says make button enabled or disabled based on conditions.
    Let's say if field1= sth && field2= sth

    so even though Role1 and Role2 don't have duty/privilege that would give them access to this button. They can still see it and access it because of the x++ code (if the conditions are met)

    So it seems x++ code overrides privileges and duties.
  • Martin Dráb Profile Picture
    239,866 Most Valuable Professional on at
    So what do you want from us? You're saying that you have code that you don't want, so why don't you remove it? Do you mean that you can't remove it because it's in someone else's package and you forgot to say that?

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 461 Super User 2026 Season 1

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2026 Season 1

#2
Subra Profile Picture

Subra 428

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans