What is an Indexed Sub Process in Savvion
In one of my last projects we had a requirement that a certain approval needed to be done by N number of groups where the actual number and groups were supposed to be deciphered during runtime. Actually there was a workstep where the performer would choose from a list which all groups need to complete the task. Additional requirement was that the comments and action (Approve/Reject) taken by each of them should be available in the audit trail.
Savvion Supports Indexed Sub Processes which allow you to have better control over how processes are created and used. When you want to decide on runtime how many processes should be created, indexed process is the right approach.
Here is how you can setup one. Create a normal sub process with the standard dataslot mappings you would do in a regular sub process. For example, assume our sub process has only one workstep “Approver” whose performer is a String dataslot called “dsApprover”. Now for indexed sub process to work correctly we will need to define a few LIST dataslots on the parent process.
- The first list dataslot will be a list of sub processes names. If all your subprocess instances would be same, add N number of entries (string). i.e. the list should look like [“MySubProcess”, “MySubProcess”, “MySubProcess”, “MySubProcess”]. Then assign this list dataslot as the performer for the subprocess workstep. What this means is that when the execution reaches this step, we will have four instances of MySubProcess that would be created (This is how you achieve the dynamic number of sub processes requirement)
- Next, Identify the input and output dataslots. For example in this case the dsApprover dataslot of the sub process has the performer. So define a List dataslot on the parent process which has exactly the same number of entries as the performer list dataslot. Add entry for each group that should execute the Doer workstep of sub process. i.e. this dataslot should look like [“group1”,”group2”,”group3”,”group4”]. Now map this dataslot to the dsApprover dataslot of the sub process. During runtime when the sub processes are created, the value group1 goes to the first instance, group2 goes to the second instances and so on.
- Now, to get the comments and action taken by the sub process we define two more list dataslots called “subprocessComments” and “subProcessActions”. We will map it to the comments and action dataslots of the sub processs. When the sub process finishes the value will come back to the parent process in the list dataslot thereby finishing the operation.
Here care must be taken that when the values come back from the subprocess they may not be ins the same order as the processes are created. Rather the order is on the basis of how the processes are completed. In order to do the correct reconciliation, you will need to use some kind of prefix in your values itself. i.e. rather than sending back “approve”, you can send back “group3#approve”.
Another benefit if this approach is that by changing the template name in step 1 you can achieve heterogeneous sub processes i.e. five instances two of which would be of template type A and 3 of Template Type B.
There could be several other scenarios where indexed sub processes could be helpful.
Hope this helps.