AX – D365FO – X++ code to find all the Duties related to specific Privileges in AX 2012

static void findAllTheDutiesForSpecificPrivileges(Args _args)
        SecurityTask             securityTask;
        SecuritySubTask       securitySubTask;

        #define.SecurityTask("AbbreviationCodeImport_Import_RU") // your privileges name

        select firstOnly RecId from securityTask
                  where securityTask.AotName == #SecurityTask
                  && securityTask.Type == SecurityTaskType::Privilege;

          while select SecurityTask from securitySubTask
                    where securitySubTask.SecuritySubTask == securityTask.RecId
                     select firstOnly * from securityTask
                                 where securityTask.RecId == securitySubTask.SecurityTask;
            info(strFmt(“%1,%2,%3″, securityTask.AOTNAME, securityTask.Name, securityTask.Type));

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s