Oracle SOA Suite Online Training

Interested in learning Oracle SOA Suite 12c?
Learn from the author of this blog!
A complete and comprehensive course on the #1 platform on SOA - Oracle SOA Suite

Click here to find the complete course details
Click here to check the first session on Oracle SOA Suite 12c

================================================================================================

Multi-Instance Processing in BPM - Iterating over Arrays in BPM

It is often a common scenario to trigger multiple instances of a particular part of a BPM process. A typical example would be
You have an array as input, and the same process to run for each of the element set in this array(each element may refer to a particular user tasks)
OR

Every night, a batch process to run and each of the managers in the organization to be notified with the to-be-reviewed activities assigned to them ie, each person should be notified only with his tasks which requires a particular process to be run for each of the managers

NOTE :
This post specifically applies to Oracle BPM Suite 11g 11.1.1.5, before the FeaturePack(FP). In this version, the LoopCounter Variable in the subprocess is not visible, which is a bug. And this post is the workaround for that.
Post FeaturePack release, the variable is available in the Sub-Process, so the process of assigning the individual input in the script task at the starting of the Sub-Process is not required. I'll write another blog for it.

In this example,
 there are several managers, and a separate instance of the sub-process(shown below) is to be triggered to each of the managers, paralelly


Input to the sub-process has to be of type Array – thumb rule ;) – as only then, you can split the data  and make each of the instances get corresponding data
Schema for the input to the sub-process is given at the end of the post

There is a way to instantiate parallel processes in BPM, and that’s called MultiInstance invocations
1.       Create a sub-process and, create the activities that are required to repeat for each manager
2.       Now, this should be invoked for all the elements in the array. So some configuration  to be done to the sub-process property
My process looked like below

3.       Double click the sub-process à


Select multiinstance as loop characteristic
Cardinality is no. of instances to be produced, here it is count (allActivities.reviewerWiseActivities, which otherwise is equal to no. of managers - with tasks)
Uncheck Is Sequencial
Don’t touch Arguments definition tab, as since this is a pre-Feature pack release, there is a bug and you cannot go with the standard way
1.       Input to the sub process is an array, but typically each manager has to be assigned only with his tasks, which will be one element in the array. So use a script task as the first activity in the sub-process and copy nth element from the array and assign it to sub-process dataobject



Here, the value in the left box is :: AllActivitiesPDO.reviewerWiseActivities[loopCounter] which is obvious to understand.

Bug in Pre-Feature pack release is that this loop counter is not available in the properties window of the sub process. That’s the reason, we are splitting the array within the subprocess but not before invoking the subprocess.
Had this been post Feature pack release, you can split the array in the properties window of the subprocess, define input and output elements, and skip this script task.

That’s it! Now, n number of sub process instances will start paralelly

Hope this is useful J

Input Schema

<?xml version= '1.0' encoding= 'UTF-8' ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org" targetNamespace="http://www.example.org"
     elementFormDefault="qualified">
    <xsd:complexType name="IndActivity">
        <xsd:sequence>
            <xsd:element name="ActivityId" type="xsd:int"/>
            <xsd:element name="ActivityName" type="xsd:string"/>
            <xsd:element name="PlannedFinishDate" type="xsd:dateTime"/>
            <xsd:element name="AttachmentLoc" type="xsd:string"/>
            <xsd:element name="reviewerApproval" type="xsd:string"/>
            <xsd:element name="strAttribute1" type="xsd:string"/>
            <xsd:element name="strAttribute2" type="xsd:string"/>
            <xsd:element name="intAttribute1" type="xsd:int"/>
            <xsd:element name="intAttribute2" type="xsd:int"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="IndReviewerActivities" type="ReviewerActivitiesType"/>
    <xsd:complexType name="ProjectType">
        <xsd:sequence>
            <xsd:element name="ProjectId" type="xsd:int"/>
            <xsd:element name="ProjectName" type="xsd:string"/>
            <xsd:element name="Activities" type="IndActivity" maxOccurs="unbounded"/>
            <xsd:element name="strAttribute1" type="xsd:string"/>
            <xsd:element name="strAttribute2" type="xsd:string"/>
            <xsd:element name="intAttribute1" type="xsd:int"/>
            <xsd:element name="intAttribute2" type="xsd:int"/>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="AllActivities">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="ReviewerWiseActivities" type="ReviewerActivitiesType" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>
    <xsd:complexType name="ReviewerActivitiesType">
        <xsd:sequence>
            <xsd:element name="ReviewerLoginId" type="xsd:string"/>
            <xsd:element name="ReviewerIntExt" type="xsd:string"/>
            <xsd:element name="Project" type="ProjectType" maxOccurs="unbounded"/>
            <xsd:element name="strAttribute1" type="xsd:string"/>
            <xsd:element name="strAttribute2" type="xsd:string"/>
            <xsd:element name="intAttribute1" type="xsd:int"/>
            <xsd:element name="intAttribute2" type="xsd:int"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

2 comments:

  1. thank you very much. A question, I can to assign each data object to diferent roles?

    ReplyDelete
  2. Yes, you can do that in the Assignments tab of the Human Task activity inside the loop

    ReplyDelete