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 :
Microsoft Dynamics AX (Archived)

How to add access level to privilege with code?

(0) ShareShare
ReportReport
Posted on by 932

Hi,

I want to get the access level of privilege with code :

1581.access.png

I want to add switch case statement to my code : How can I declare the  value of access level in the statement?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    AOT > System Documentation > Enums > AccessRight has those options I believe.

    So you can do it via the AccessRight enum.

    But to be sure you could check the enumeration behind the SecurityPermission tables' Access field where this information is stored, using reflection (Dict* classes like DictEnum maybe?)

  • BASMA Profile Picture
    932 on at

    Sorry I don't understand your suggestion:

    in AccesRight :NoAccess,View,Edit,Add,Correction,Delete.

    in AccessLevel of privilege:NoAccess,Read,Update,create,correct,delete.

    Can I do like this??

    switch(_node.AOTgetProperty(#AccessLevel))

           {

               case AccessRight::Add:

                eukSecTreeNode.SecurityLevel=EUKSecurityLevel::Delete;

           }

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Yes.

    And here is what I have explained above:

    static void Job1(Args _args)
    {
        info(strFmt('%1',
            enumId2Name(
                new DictField(
                    tableNum(SecurityPermission),
                    fieldNum(SecurityPermission, Access))
                .enumId()))
            );
    }
  • Vilmos Kintera Profile Picture
    46,149 on at

    Also in the code that you took a screenshot of above, you are using a TTS block around an insert, which is not necessary, unless you want to catch errors like a duplicate key exception.

  • BASMA Profile Picture
    932 on at

    I have errror when I compare AccessLevel with AccessRight :

    switch(_node.AOTgetProperty(#AccessLevel))

          {

              case AccessRight::Add:

               eukSecTreeNode.SecurityLevel=EUKSecurityLevel::Delete;

          }

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    Because you are comparing a string value against an enumeration. Typical apples to bananas situation, the error message is very clear about this.

    Convert it to a proper enum value.

    [View:https://docs.microsoft.com/en-us/previous-versions/dynamics/ax-2012/reference/aa655065(v=ax.60):750:50]

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans