Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Tuesday, June 24, 2014

Job to list out all roles to current user in Dynamic AX

Hi,

static void AlfasithListOutRoles2User(Args _args)
{
    SecurityRole        role;
    SecurityUserRole    userRole;
    boolean             added;
    UserInfo            userInfo;
    ;
    while select * from userRole
            where
                userRole.User == xUserInfo::find().id
    while select role where role.RecId == userRole.SecurityRole
    {
        info(strFmt("%1 --- %2",Role.Name,Role.RecId));
    }
}

Regards,

Job to assign the user role to all user in that instance in Dynamic AX

Hi,

static void AssignUserRights(Args _arg)
{
   SecurityRole        role;
    SecurityUserRole    userRole;
    boolean             added;
    UserInfo            userInfo;
    ;

    select role where role.Name == "Accountant";
    while select userInfo
    {
        select * from userRole
            where userRole.SecurityRole == role.RecId &&
                userRole.User == userInfo.id;
            if (!userRole || (userRole.AssignmentStatus != RoleAssignmentStatus::Enabled))
        {
            info(strFmt('Role %1 added to the user %2 successfully.', role.Name, userInfo.id));

            userRole.User = userInfo.id;
            userRole.SecurityRole = role.RecId;
            userRole.AssignmentMode = RoleAssignmentMode::Manual;
            userRole.AssignmentStatus = RoleAssignmentStatus::Enabled;
            SecuritySegregationOfDuties::assignUserToRole(userRole, null);
        }
        else
        {
            warning(strFmt('skipping – Role %1 to the user %2.', role.Name, userInfo.id));
        }
    }
    pause;
}

}

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...