Many use cases and common scenarios in the world of ENOVIA triggers exist that necessitate pushing the context to a user with elevated privileges. Several well established Java APIs [ContextUtil.pushContext()] allow developers to accomplish this task where necessary. Many OOTB processes and triggers use these APIs as well.
However, what if you have a trigger that runs downstream of another process that has pushed the context? When a super user has been pushed, you will see the context set to "User Agent," but often, you need to know the user that performed the original operation. There are many reasons that this could be necessary in your trigger, such as data creation, enforcement of access control or even having appropriate user names on notifications.
Luckily, there is a solution to this problem! A session RPE value is available called MX_LOGGED_IN_USER_NAME. One of the reasons this value is set is so that in the event the context is pushed, all downstream processes can still have access to the user name that performed the original operation.
The RPE value can be accessed either via a Java API [ PropertyUtil.getGlobalRPEValue(context, "MX_LOGGED_IN_USER_NAME") ] or from MQL by use the command [ get env MX_LOGGED_IN_USER_NAME ].
Hopefully you will find this helpful the next time you retrieve the context inside a trigger and get an unexpected "User Agent" in return.
Tips and Tricks
