User contexts for startable plugins

If you use the simplest method signature for the execute method on StartablePluginCallbackHandler, your code does not run with a current PolicyCenter user. Any code that directly or indirectly runs due to this plugin—including pre-update rules or any other code—must be prepared for the current user to be null. You must not rely on non-null values for current user if you use this version.

However, there are alternate method signatures for the execute method. Use these to perform your startable plugin tasks as a specific User. Depending on the method variant, pass either a user name or the actual User entity.

On a related note, the gw.transaction.Transaction class has an alternate version of the runWithNewBundle method to create a bundle with a specific user associated with it. You can use this in contexts in which there is no built-in user context or you need to use different users for different parts of your tasks.

gw.transaction.Transaction.runWithNewBundle(\ bundle -> YOUR_BLOCK_BODY, user)

For the second method argument to runWithNewBundle, pass either a User entity or a String that is the user name.