Script Contexts
There are two different script context types:
Both are based on ScriptContext and this is what they both have in common.
ProcessScriptContext
The ProcessScriptContext contains the input and output documents, in addition to the information in ScriptContext. A Document consists of the document content and its (dynamic document) properties.
public List<Document> inputDocuments = []
public List<Document> outputDocuments = []Process ScriptContext example
The following examples demonstrates how to setup all kind of properties and documents to run a process script.
ProcessScriptContext context = new ProcessScriptContext()
// Initialize
// * Execution context : executionContexts
// * Dynamic Process Properties : dynProcPros
// * Process Properties : procPros
// * Documents : inputDocuments
// incl. Dynamic Document Properties
// --------------------------------------------------------------
// context.executionProperties.ACCOUNT_ID = "My Account ID"
context.dynProcPros.DPP_ProcPropString = "My Process Property"
context.dynProcPros.DPP_IntValue = 0
// region Process Property
final String PROCESS_PROPERTY_COMPONENT_ID = "8fb41f63-a988-4778-8cc8-0144f30ace81"
final String VAL1_ID = "eea9e988-cb14-4a84-ba37-ee455451a741"
final String VAL2_ID = "2c68fb60-8431-46cc-9da9-cbe10d446a0e"
// Wrap key in parenthesis so that the variables (Ids) are taken
// and not the text as a string
def procPropValue1 = 4711
def procPropValue2 = "Markus Schmidt"
context.procPros = [ (PROCESS_PROPERTY_COMPONENT_ID):
[
(VAL1_ID): procPropValue1,
(VAL2_ID): procPropValue2
]]
// endregion
// region Documents
final String DDP_Name = "DDP_IntValue"
int[] ddpValues = [ 10, 11, 12]
context.inputDocuments =
[
Document.fromText('''
{
"firstname" : "Walter",
"lastname" : "Schmidt"
}''', [(DDP_Name): ddpValues[0]]),
Document.fromFile( _testFiles.get( "demoDoc01.json") , [(DDP_Name): ddpValues[1]]),
Document.fromFile( _testFiles.get( "demoDoc02.json") , [(DDP_Name): ddpValues[2]])
]
// endregion
_testScript.run(context)MapScriptContext
A MapScriptContext represents the input and output variables as they are defined on the platform, in addition to the information in ScriptContext.

ScriptContext
The ScriptContext is the base class,MapScriptContext and ProcessScriptContext inherit from it. The ScriptContext hosts:
Process Properties - procProps
Dynamic Process Properties - dynProcProps
Execution Properties - executionProperties
If you want to use ExecutionTask objects in your scripts,
read also about The Process Call Chain
Last updated