static void CopyUserSettings(Args _args)
{
Dialog dialog = new
Dialog("Copy user settings");
DialogField fldFromUser, fldToUser;
UserId fromUser, toUser;
SysLastValue sysLastValue;
int counter = 0;
fldFromUser = dialog.addField(extendedTypeStr(UserId), "From user", "The
user to copy settings from");
fldToUser = dialog.addFieldValue(extendedTypeStr(UserId), curUserId(), "To
user", "The user to copy settings
to");
dialog.run();
dialog.wait();
if
(dialog.closedOk())
{
fromUser = fldFromUser.value();
toUser = fldToUser.value();
if
(SysUserInfo::find(fromUser).RecId && SysUserInfo::find(toUser).RecId
&& fromUser != toUser)
{
if
(Box::yesNoCancel(strFmt("Delete all user settings for %1?",
toUser), DialogButton::Cancel) == DialogButton::Yes)
{
info(strFmt("Copying user
settings from %1 to %2", fromUser, toUser));
ttsBegin;
delete_from
sysLastValue where
sysLastValue.userId == toUser;
while
select sysLastValue where sysLastValue.userId == fromUser
{
sysLastValue.userId =
toUser;
sysLastValue.insert();
counter++;
}
ttsCommit;
info(strFmt("%1 records copied
from %2 to %3", counter, fromUser, toUser));
}
else
{
info("Copy
canceled");
}
}
else
{
throw
error("Invalid / non existing users or same
user selected for copy action");
}
}
else
{
info("Copy
canceled");
}
}
1 comments:
Write commentsI tried , Looks like it not copying the Roles. It copies the User settings from syslastvalue
ReplyEmoticonEmoticon