Skip to content

Commit d85350c

Browse files
authored
Implement user impersonation activity logging
Code to be added to the Business rule to track the changes
1 parent a77fcfa commit d85350c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
if (new GlideImpersonate().isImpersonating()) {
3+
// Check if the user is impersonating
4+
if (current.comments.changes() || current.work_notes.changes()) {
5+
// Check if comments or work notes have changed
6+
let actualUserName = gs.getImpersonatingUserDisplayName();
7+
let impersonatedUserName = gs.getUserDisplayName();
8+
let logMessage = `User Impersonation Activity Detected:
9+
Timestamp : ${new GlideDateTime()}
10+
Actual User: ${actualUserName}
11+
Impersonated User: ${impersonatedUserName}
12+
Comments added: ${current.comments || "NA"}
13+
Work Notes added: ${current.work_notes || "NA"}`;
14+
gs.info(logMessage);
15+
}
16+
}
17+
})(current, previous);

0 commit comments

Comments
 (0)