Find role of employee - Microsoft Dynamics 365 Vietnam

Microsoft Dynamics 365 Vietnam

Song Nghia - Microsoft Dynamics 365 Vietnam

Breaking

Friday, November 22, 2019

Find role of employee

Song Nghia - Technical Consultant

Find role of employee

class SCA_FindRoleOfUser

{     

    /// 

    /// Runs the class with the specified arguments.

    /// 

    /// The specified arguments.

    public static void main(Args _args)

    {

        SecurityRole        role;

        SecurityUserRole    userRole;

        UserInfo            userInfo;

        // Check the AOT macro for the path names

        #AOT



        SysModelElement         sysModelElement;

        treeNode treeNode;

        ;



        //nghia.song start syncdatabase

        appl.dbSynchronize(tableNum("SecurityRole"));

        appl.dbSynchronize(tableNum("SecurityPrivilege"));

        appl.dbSynchronize(tableNum("SecurityUserRole"));

        appl.dbSynchronize(tableNum("SecurityDuty"));

        appl.dbSynchronize(tableNum("SecurityEntryPointInferredTables"));

        appl.dbSynchronize(tableNum("SecurityRoleAssignmentRule"));

        appl.dbSynchronize(tableNum("SecurityRoleDutyExplodedGraph"));

        appl.dbSynchronize(tableNum("SecurityRoleExplodedGraph"));

        appl.dbSynchronize(tableNum("SecurityRolePrivilegeExplodedGraph"));

        appl.dbSynchronize(tableNum("SecurityRoleRuntime"));

        appl.dbSynchronize(tableNum("SecuritySegregationOfDutiesConflict"));

        appl.dbSynchronize(tableNum("SecuritySegregationOfDutiesRule"));

        appl.dbSynchronize(tableNum("SecuritySubRole"));

        appl.dbSynchronize(tableNum("SecurityUserRole"));

        appl.dbSynchronize(tableNum("SecurityUserRoleCondition"));

        //nghia.song --end

        while select firstonly  role

        exists join userRole

        where role.RecId     == userRole.SecurityRole

              && userRole.User == "VNBMH"

        {

            info(strFmt("%1  -  %2", role.Name, curUserId()));

        }

    }



}