In a nutshell, multi-instance subprocesses allow you to execute a specific set of actions a specified number of times either in sequence or in parallel.
What shouldn't be confused is the difference between repetitions and multi-instances. Multi-instances will create a snapshot of a specific set of actions and data, and run it a specified number of times, with each instance living in it's own private memory space.
Repetitions on the other hand is executing the same actions and data a specified number of times, with both actions and data sharing the same context, therefore being capable of being executed in a sequence manner.
So let's see all this in practise. In the following steps, I will be creating a sample form-initiated based process where the user will define the number of loops (executions) a subprocess, that will include of a simple "Submit Task" should execute.
Create a new application in Oracle Process Cloud Service, give it a name and file it under a space (I've named it "Multi-Instance Subprocesses Demo App" under a custom space called "aantoniou").
Next create a sample process using the "Form" pattern.
The first that that we will do is to define the implementation details of the very first component of our process which is the actual form. So open the properties of the "Start" component and specify a title and then create a new web form.
On the canvas of your new web form drag and drop just one components; a number field component and your number field component numberOfLoops.
Save and close your web form to return to your demo process. Next we will add the actual subprocess. So expand the "System" component group and drop between the "Start" and "End" activities a sub-process component.
In between the "Start" and "End" activities of the sub-process component drop a "Submit" activity.
Open the properties of your subprocess to define its implementation details. In the repetition cycle select "Generate multiple instances", in the multi-instance type select "In Sequence" and select "Condition" as the repetition condition type. In the "How many instances do you want to create" use your form numberOfLoops variable to define the number of instances.
You can also use an array instead of a condition that will be used by the subprocess to identity the number of loops that it should execute. Furthermore, you can define an output (or a results) array that the subprocess will use to store the results of the subprocess.
Hint: the numberOfLoops form variable has been automatically created for you as a double. Please use the int() function to convert the double to an int.
Publish your changes and deploy your application. Make sure you specify a version number in the deployment dialog.
Before you can start testing your process, you need to map a user (or a group) to the "Process Owner" application role of your process.
Click on the "Start Application" global menu link and click on your process. Specify some sample data and the number of loops and click "Submit".
Go to your tasks and you should have one task in your inbox.
Submit your first task and go back to your inbox. You should see the second task in your pending tasks.
Submit your second task and go back to your inbox. You should see now the third and last task in your pending task list.
Let's change the instance creation type from sequential to parallel. Go back to your process and open the properties of your subprocess activity and change the "How do you want to manage your instances" type to "In Parallel.
Publish your changes and deploy a new version of your process (make it as default as well).
Start a new instance of your application using again the same number of loops (3).
Go to your tasks inbox and you should now see all three tasks appearing at the same time in your pending tasks list.