Requirement:
A developer wishes to use a transient variable between the Before Submit and After Submit entry points of a User Event script.
Solution:
One of the ways to have this done is to define a session object on the Before Submit script using the ‘runtime.Session’ method found in the runtime record. The After Submit block will get the value of this session object using the ‘session.get’ method.
Example:
// Add additional code
...
var sessionObj = runtime.getCurrentSession(); //sessionObj is a runtime.Session object
sessionObj.set({
name: 'myKey',
value: 'myValue'
});
log.debug('Session object myKey value: ' + sessionObj.get({name: 'myKey'});
...
// Add additional code
The code above lets you create a session object in the before-submit context and access the variable stored in the session object in the after-submit context and vice versa. This method overcomes the barrier of not being able to use a common global variable between these two instances in the script.