Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

hide/show buttons for a specific role depending on specific criteria

Posted on by 15

Hi everyone

i m trying to grey out " release to warehouse" button depending on a specific value of column in sales table and all this for a specific role

i m working in pharmaceutical industry and we have added a column in sales tables to define if the sale order contains psychoactive drug or not so if it is, the " release to warehouse" sould be greyed out

please can you help me

Peace

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: hide/show buttons for a specific role depending on specific criteria

    Hi Pharma,

    At least the system table SecurityRole contains the information you are looking for.

  • Pharma Profile Picture
    Pharma 15 on at
    RE: hide/show buttons for a specific role depending on specific criteria

    hi

    which ax function could give me the aotname of a role

    for example i want to use your function IsUserInRole

    how can i get the argument rolename for a "SalesManger" Role for example

    hope i ve been explicit

    thank you

  • Pharma Profile Picture
    Pharma 15 on at
    RE: hide/show buttons for a specific role depending on specific criteria

    hi

    thank you so much

    but i have one more question , i want to use your function " IsUserInRole "

    my question is how to get the AOT rolename of a role for example "SalesManager" role

    thank you by advance

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: hide/show buttons for a specific role depending on specific criteria

    Hi Pharma,

    Here is also documentation about avialable methods on form data sources.

    docs.microsoft.com/.../methods-on-a-form-data-source

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: hide/show buttons for a specific role depending on specific criteria

    Hi Pharma,

    If you can't find the active method on a datasource, you can right click the method node and choose to create a new override method for active().

  • Pharma Profile Picture
    Pharma 15 on at
    RE: hide/show buttons for a specific role depending on specific criteria

    hi Sergei

    thank you for your response

    so i am a beginner and i want to know more about the solution you ve proposed

    i m stucked on step 2

    where can i find this 'active method"

    thank you

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: hide/show buttons for a specific role depending on specific criteria

    Hi Pharma,

    In addition to the reply from Sergei... It might be the case that there is existing logic in the application which controls the behavior of this button. In that case, you have to extend this logic with your requirements.

  • Suggested answer
    Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: hide/show buttons for a specific role depending on specific criteria

    Hi Pharma,

    Usually, you need to make the next steps:

    1. Change "AutoDeclaration for the button to "Yes" on a form to be able to access the button from the code.

    2. On active method for data source after "super" you call enable method on button variable with true or false (button.enabled(false))

    3. if you want to implement this change only for a specific role you have several options

    3.1. Make a copy of button with new privilege and give access to the specific role and remove access to the old button

    3.2. Add parameter with the role selection and implement the function to check if the user has a role from parameters - similar to blog.andrewhuey.com/.../

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans