How to Assig access rights in Axapta between users

 How to Assig access rights in Axapta between users

Assignment of access rights for the users is a very frequent task. This script helps to assign or replicate the access rights between users instantly.


// Script for assigning/swapping access rights between users.
static void assignAccessRights(Args _args)
{
UserGroupList groupList,groupListIns;
str 10 frmUser, toUser;
;

frmUser = 'usr1';
toUser = 'usr2' ;

// To delete the existing permissions of the toUser
delete_from groupList
where groupList.UserId == toUser;


while select groupList
where groupList.userId == frmUser
{
info(strfmt('Group assigned: %1',groupList.groupId));
select forupdate groupListIns
where groupListIns.userID == toUser
&& groupListIns.GroupId == groupList.GroupId;

if(!groupListIns)
{
groupListIns.UserId = toUser;
groupListIns.GroupId = groupList.GroupId;
groupListIns.insert();
}
}
info(strfmt('Permissions changed from: %1 to: %2',frmUser,toUser));
}

-Harry

Comments

Popular posts from this blog

Connecting to Databases through X++ PART -I

X++ code for document attachment

Multiple Tables In Query