Fuego.Lib : ProcessInstance

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.

Example 1

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.

Important: The creation of process instances obeys transaction semantics: process instances are effectively created after (and only if) the activity running the script finishes successfully.
args as Any[String]
args["descriptionArg"] = "AutoInstance: " + formatTime('now', timeStyle : Time.SHORT)
args["genByArg"] = "Automatic"
ProcessInstance.create(arguments : args, argumentsSetName : "BeginIn")

Example 2

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

Example 3

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.

Important: The creation of process instances obeys transaction semantics: they are effectively created after (and only if) the activity running the script finishes successfully.
for each line in Fuego.Io.TextFile("/incomming/articles.txt").lines
do
  ProcessInstance.create(arguments : ["titleArg": line ],
                  argumentsSetName : "BeginIn")
end

Example 4

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

Example 5

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

Example 6

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
 

Example 7

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