web
You’re offline. This is a read only version of the page.
close
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

Add role through x++

(0) ShareShare
ReportReport
Posted on by 390

Hey team,

How can i add a role "Accountant" to my user using x++?

I have the same question (0)
  • Suggested answer
    Sergei Minozhenko Profile Picture
    23,093 on at

    Hi Skd,

    You can check article dynamicsaxgyan.wordpress.com/.../

    May i ask you why do you want to do this from x++?

  • Blue Wang Profile Picture
    on at

    HI Skd,

    Please refer to Andre’s blog about automatic role assignment, It is still valid for Dynamics 365.

    dynamicspedia.com/.../

    dynamicspedia.com/.../

    And this github.com/.../dyn365-1.0.0

  • André Arnaud de Calavon Profile Picture
    301,141 Super User 2025 Season 2 on at

    Hi skd,

    Can you provide why you want to use x++ to assign roles to users? Blue shared some links to my blog related to automatic role assignment. You can review them and setup rules instead of x++ coding.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi skd,

    Agree with Andre here.

    Why do you need to code something to add users.

    Unless you add a lot of users on a daily basis, you can use the standard functionalities that we have available in the D365FO client to add your users manually.

    That seems to be the fastest and cheapest way to me.

    Best regards,

    Ludwig

  • Hugo Alves Profile Picture
    129 on at

    I am searching community for the same question and
    the piece of code in Sergei's link is the answer!
    Thank you Sergei.

    I don't understand this question "why you want to make it?"?
    SKD asked a totally relevant question.
    No need to long explanations, but ok if anyone wants to know the reason, i can give you mine...

    We don't want to open doors for a System App (AAD) in upper environments (UAT, QA, PRD...)
    So i do my setup in DEV, where third party is testing new OData and API.
    (Before any puritan asks why in DEV, no matter we were doing so in TST we would end up with the same problem)
    As "Data Dump" occurs from upper environment onto DEV, it overrides our setup, which resides in Data level.
    We can assure Application level elements are always present (Security Role, Duties, and Privileges) but for Data level only the user comes from restored DB, roles assignment does not.

    And this long story is why i need to easily recreate a simple Role Assignment into my testing environment.
    Again, thank you Sergei for enriching community content the simple way.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 456 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans