Feb 21, 2022

A simple job to get roles and assigned duties

 static void HRolesAndDuties(Args _args)

{

    SecurityRole            securityRole;

    SecurityRoleTaskGrant   securityRoleTaskGrant;

    SecurityTask            securityTask;

    HSecurityDutiesperUser   hsecurityDutiesperUser; // my table to store the details

    boolean                    Created;



delete_from hsecurityDutiesperUser;


    while select  securityRole

        where securityRole.AotName like '*'

            join  securityRoleTaskGrant

            where securityRoleTaskGrant.SecurityRole == securityRole.RecId

                join securityTask

                where securityTask.RecId == securityRoleTaskGrant.SecurityTask &&

                      securityTask.Type  == SecurityTaskType::Duty

    {

       hsecurityDutiesperUser.Role   = securityRole.Name;

        hsecurityDutiesperUser.Duty   = SysLabel::labelId2String(securityTask.Name) ? SysLabel::labelId2String(securityTask.Name) : securityTask.Name;

        hsecurityDutiesperUser.Type   = securityTask.Type;

        hsecurityDutiesperUser.insert();

        Created = true;


    }

    if(Created)

    {

        Info(' Roles and duties info generated successfully');

    }

}

No comments: