Here’s a little job that helped me resolve issues related to user settings in AX. It copies user settings / usage data from one user to another. Usually when a user is having an issue with a specific form the first thing to do is delete all usage data related to that form. In case you want reproduce that issue yourself you need to copy the settings from that user, so I wrote a little job that does just that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
static void Util_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"); } } |
The output when running the job