To illustrate the Group by feature we will use the Students Application Process described in previous sections.
In a school, several students have to be enrolled in order to assist to class. The applications of the students must be received and then an enrollment Process should be created: one for each student. The business situation can be modeled as shown in the following diagram:
There is a parent Process called Students Application and a multiple Sub-Process called Student Enrollment.
Both Processes have been diagrammed in the Process Modeler and Process Entities defined for each one.
Students Application is the Process entity of the Students Application Process and the Students Enrollment by Gender entity is the Process entity of the Sub-Process Students Enrollment.
In order to create the Multiple Sub-Process instances a collection is defined for the parent Process. This collection is called Students Enrollment
We wish to manage the enrollments by gender, accordingly we will create a Student Enrollment Sub-Process instance for boys and another Sub-Process for girls as shown in the image below.
To group instances of this Sub-Process by gender follow the next steps:
1. Go to step 1 (Model Process) of the Process Wizard and click Edit Process. Select the parent Process called Students Application.
In the model diagram, right-click the Task you wish to convert, in this case Students Enrollment, and select the option Transform to Sub-Process option.
A new window will display the Sub-Process types. Select the Multiple option and click Next.
2. Select the process to be transformed, Student Enrollment, from the drop-down list, choose the version and click Next.
Once the associated diagram to the Sub-Process has been selected, choose the Advanced settings option and click Next.
3. Select the collection for the Sub-Process grouping. In this case we group by StudentsApplication.StudentsEnrollment collection.
Also select the number of instances. We will determine the number of instances to create using a collection. Select the Items in Collection option.
4. In the last window of the Wizard, select the option Group by. The wizard will ask you to define the collection to be grouped, in this case the collection StudentsEnrollment. Once it has been defined, the Wizard will advise you that a relationship must be defined between such entity and the current Sub-Process entity.
Click Yes to establish that relationship automatically. Then click Next
5. Select the attributes by which you wish to group. Select the attribute from the box on the left and then click the right-pointing arrow to add it. To remove an attribute select the it from the box on the right and then select the left-pointing arrow.
We will group by gender. Click Next
Relationship to the parent Process
When you execute the Process you will find that it is not possible to access the parent Process' information since no automatic mapping is done. This means, that there is no relationship between the Sub-Process entity and the parent Process entity. There are relationships between the parent Process Entity and the grouped entity and between the Sub-Process Process entity and the grouped entity.
It is necessary to define the missing relationship to be able to navigate all the data model and be able to reach the parent Process Process Entity.
In order to define the missing relationship between the parent Process Entity and the Sub-Process Entity follow the next steps:
1. Go to the second step of the Wizard and click Model Data for the parent Process.
2. A new window will display. Right-click the Sub-Process Process entity (Students Enrollment by Gender) and select the option Edit Attribute List.
3. Create a new attribute clicking on Add and typing the display name. Select the parent Process Entity to be related.
In this case we type Student Application and select the Student Application Entity from the Master entities list.
4. The missing relationship is established and the data model updated.
5. Now it is necessary to create an expression that enters the necessary data to the new relationship.
Define an on enter expression on the first Activity of the Sub-Process. It will get the ID of the parent Process Entity and set it in the Sub-Process entity.
The expression in this example would be:
With the relationship created and the mapping expression you will be able to access to the data of the parent Process context normally through the Student Application Relationship
To group Sub-Process instances take into account that the Process entity of the multiple Sub-Process and the collection must be different entities.