Axapta V/s Me

Yet another blog for Dynamics 365 for Finance and Operations. This blog primarily targets the technical readers. I will be sharing my experience with Dynamics AX using code snippets, errors, and solutions, Tips, and tricks.

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;

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


No comments:

Post a Comment


Note: Only a member of this blog may post a comment.