The ProcessInstance component is used to retrieve or modify properties that are associated with the current process instance. You can also use this component to create new process instances in the current process or in other processes.
Every instance of a process is a special object instance of the ProcessInstance component. All predefined variables of a process are the attributes inherited from ProcessInstance.
In the example below, the ProcessInstance component is used create a new process instance. The Begin activity of the process has a BeginIn argument set and has two arguments.
args as Any[String]
args["descriptionArg"] = "AutoInstance: " + formatTime('now', timeStyle : Time.SHORT)
args["genByArg"] = "Automatic"
ProcessInstance.create(arguments : args, argumentsSetName : "BeginIn")
In the example below, the ProcessInstance component is used to change the description of the current process instance:
ProcessInstance.description = ProcessInstance.description + "- Nr: " + ProcessInstance.id.number
In the example below, the ProcessInstance component is used to create more than one process instance. The example reads a file as input and creates a new process instance, passing each line of the file as argument.
for each line in Fuego.Io.TextFile("/incomming/articles.txt").lines
do
ProcessInstance.create(arguments : ["titleArg": line ],
argumentsSetName : "BeginIn")
end
In the example below, the ProcessInstance component is used to create a new process instance in a different process:
newinst = ProcessInstance.create(processId : "/ProcessInstanceSubprocess",
arguments : null, argumentsSetName : "BeginIn")
display "A new instance was created in ProcessInstanceSubprocess: " + newinst
In the example below, the ProcessInstance component is used to retrieve information about the file attachments and notes of the current process instance:
for each a in ProcessInstance.attachments
do
display "Attachment: " + a.fileName + " Description: " + a.description
end
//Display Notes Information
for each n in ProcessInstance.notes
do
display "Notes: " + n.text
end
In the example below, the ProcessInstance component is used to retrieve information about the child instances of the current process instance (that is, those process instances created with a Subflow or Process Creation activity):
for each ch in ProcessInstance.children
do
display "Children: " + ch
end
In the example below, the ProcessInstance component is used to retrieve information about the process instance:
display "New Instance Description: " + ProcessInstance.description +
"\nID: " + ProcessInstance.id.id +
"\nNumber: " + ProcessInstance.id.number +
"\nCopy: " + ProcessInstance.id.copy
deadline = 'now' + '6m'
display "\nCreation Participant: " + ProcessInstance.creation.participant +
"\nCreation Time: " + ProcessInstance.creation.time +
"\nDeadline: " + ProcessInstance.deadline +
"\nTimeout: " + ProcessInstance.timeout +
"\nPriority: " + ProcessInstance.priority +
"\nReception Time: " + ProcessInstance.receptionTime
display "Instance status (get): " + ProcessInstance.getInstanceStatus(instanceId : ProcessInstance.id.id) +
"\nProcessInstance Status: " + ProcessInstance.status
display "Activity Name: " + ProcessInstance.activity.label +
"\nProcess Name: " + ProcessInstance.process.name +
"\nParticipant: " + ProcessInstance.participant.id
display "Parent: " + ProcessInstance.parent +
"\nResult: " + ProcessInstance.result