Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

form control need to disabled based on role in AX 2012 R3

(0) ShareShare
ReportReport
Posted on by 6

hi All,

I have create a new role like "Product receipt".

My requirement is ,

Suppose , If I assign this role to specific user, the particular user when open the Posting Product Receipt form below marked option should be disabled.

*** This should be applicable for only one entity.

AP - Receive - Product Receipt - Posting Product Receipt

Kindly let me know how will achieve this?

Please give me more shed on this.

thanks!

  • Suggested answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: form control need to disabled based on role in AX 2012 R3

    You can open a field in the parameter table and keep it there, or you can use a Macro as in the example below.
    However,in these solutions too, if the name of the relevant role in AOT is changed, it will fail. Basically, there is no serious difference from writing hardcode.

    #SysSecRole
    
    // Production Manager = 'ProdProductionManager'
    select firstonly AotName, RecId from securityRole where securityRole.AotName == #RoleProdProductionManager;

  • @rp@n Profile Picture
    6 on at
    RE: form control need to disabled based on role in AX 2012 R3

    thanks Ergun,

    In the above code , I have to hardcoded the role right? then only we can validate the role is having the user or not .

    am i right?

  • Suggested answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: form control need to disabled based on role in AX 2012 R3

    Exactly what kind of sample do you want? Actually, you have everything you need right now.

    You can use the above code to check if the user is included in that role.

    You can check which company you are in with "curExt()".

    You can use "args.caller" if you are going to add a special control about the form you came from

    Lastly, You can write this process in the init of the form.

    The rest is to combine this information and decide to disable/enable the control.

  • @rp@n Profile Picture
    6 on at
    RE: form control need to disabled based on role in AX 2012 R3

    Hi Krishna,

    thanks!

    do you have any code sample? 

  • Krishna Pushpak Profile Picture
    265 on at
    RE: form control need to disabled based on role in AX 2012 R3

    Standard Security framework within AX ,cannot provide legal entity specific restrictions .need to write the code to get desired solution

  • @rp@n Profile Picture
    6 on at
    RE: form control need to disabled based on role in AX 2012 R3

    Hi Andre,

    Thanks for prompt response.

    Sorry not understand.  Kindly elaborate me please.

    Thanks!

  • Suggested answer
    ergun sahin Profile Picture
    8,816 Moderator on at
    RE: form control need to disabled based on role in AX 2012 R3

    I agree with Andre. It's much simpler to manage with code. You can check if the user has the relevant role by modifying the code I shared below.

    The thing is, there should be a method in the global or in one of the frequently used classes, but if you use securityRole.AOTName (not sure about full Name),  with select firtOnly, it will work

    community.dynamics.com/.../list-of-security-roles-for-current-user-d365fo

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    293,112 Super User 2025 Season 1 on at
    RE: form control need to disabled based on role in AX 2012 R3

    Hi @rp@n,

    There is no deny permission in AX 2012. You can't achieve it with security configuration only. If you want to do it with help of security settings, then you need to change the form controls and set the property NeededPermission to manual. Then on the roles which would need access, you have to add specific permissions to these controls.

    It would be probably easier to do all with custom coding on this form. Check the company and role and depending on the outcome disable the buttons and make the controls non-editable.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,112 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,893 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans