Copy favorites From one user to another user - Ax 2012
Hi,
The below job is used to copy the favorites from one user to another user.
static void CopyFavoritesJob(Args _args)
{
SysPersonalization FromSysPersonalization;
SysPersonalization ToSysPersonalization;
UserId FromUserId='user01';
UserId ToUserId='user03';
;
ttsbegin;
// step 1 - delete current favorites menu from user
while select forupdate ToSysPersonalization
where ToSysPersonalization.ElementType==UtilElementType::UserMenu
&& ToSysPersonalization.UserId==ToUserId
{
ToSysPersonalization.doDelete();
}
// step 2 - duplicate from user01
while select FromSysPersonalization
where FromSysPersonalization.UserId==FromUserId
&& FromSysPersonalization.ElementType==UtilElementType::UserMenu
{
ToSysPersonalization.data(FromSysPersonalization);
ToSysPersonalization.UserId=ToUserId;
ToSysPersonalization.doInsert();
} ttscommit;
}
Note:
If the target user (User03) has any favorites, it will be deleted and imported the new favorites from source user (user01).
The below job is used to copy the favorites from one user to another user.
static void CopyFavoritesJob(Args _args)
{
SysPersonalization FromSysPersonalization;
SysPersonalization ToSysPersonalization;
UserId FromUserId='user01';
UserId ToUserId='user03';
;
ttsbegin;
// step 1 - delete current favorites menu from user
while select forupdate ToSysPersonalization
where ToSysPersonalization.ElementType==UtilElementType::UserMenu
&& ToSysPersonalization.UserId==ToUserId
{
ToSysPersonalization.doDelete();
}
// step 2 - duplicate from user01
while select FromSysPersonalization
where FromSysPersonalization.UserId==FromUserId
&& FromSysPersonalization.ElementType==UtilElementType::UserMenu
{
ToSysPersonalization.data(FromSysPersonalization);
ToSysPersonalization.UserId=ToUserId;
ToSysPersonalization.doInsert();
} ttscommit;
}
Note:
If the target user (User03) has any favorites, it will be deleted and imported the new favorites from source user (user01).
Comments
Post a Comment