-
Type: Bug
-
Status: Open
-
Priority: Minor
-
Resolution: Unresolved
-
Affects Version/s: 2021.17
-
Fix Version/s: None
-
Component/s: Automation, Comments
When creating a comment, automation scripts triggered by the following events are run as the "system" principal instead of the acting user i.e.
On CommentRoot:
- aboutToCreate
- beforeDocumentSecurityModification
- documentSecurityUpdated
- documentCreated
On Comment:
- aboutToCreate
- documentCreated
- beforeDocumentModification (to update relatedtextresources)
- documentModified
On original document:
- commentAdded
I'm particularly binding to the commentAdded event. I believe this session's principal should be the acting user, not "system".
Workaround:
Instead of using:
- CurrentUser.getPrincipal()
- Session.getPrincipal()
- input.doc.getPrincipal()
Use one of:
- var actingUser = ctx.Event.context.getPrincipal();
- var userManager = Fn.getUserManager();
var principal = Session.getPrincipal();
var actingName = principal.getActingUser();
var actingUser = userManager.getPrincipal(actingName);