Use information from the current case

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules examples >

Use information from the current case

Bizagi provides several functions that allow you to find and manipulate information about the current case. Most of this group of functions start with the sentence:

 

Me.Case

 

This group of functions are available in Current case information category.

 

 

CurrentCaseInfo5

 

 

The information available about the current case:

 

 

Property

Description

CaseId

Returns the id of the current process case.

CaseNumber

Returns the case number of the current process case.

Creationdate

Returns the creation date of the current process case.

ParentProcessId

Retrieves the parent identifier of a child process. See an example.

ParentTaskId

Returns the parent process idTask for the current process case.

ProcessState

Returns the state for the process of the current process case, it could be: Aborted, Completed, Initiated, NotInitiated, Running, Suspended.

SolutionDate

Returns or sets the actual solution date for the current process case.

CHelper.getSubProcessesId

Returns a collection with all sub-processes for the current process case instance. See an example.

getWorkItem()

Returns the work item related to a given task id. See an example.

CHelper.SiblingProcessId

Returns a collection with the sub-process' sibling cases. See an example.

CHelper.thereAreOpenProcesses

Evaluates if cases are open for a specific case creation number. See an example.

assignWorkItem

Assign a specific task (identified by the task's unique name) to a specific user. See an example.

 

 

Examples

The following examples will illustrate how to use these functions:

 

Obtain the Id of the Parent Process

Obtain the Id of the child process (sub-process) in a parent process

Obtain the Ids of sibling Processes from the current Sub-Process’ Parent Process

Evaluate if there are open processes

Obtain the WorkItem of a specific task

Assign a task to a specific user

 

 

Obtain the Id of the Parent Process

The ParentProcessId function retrieves the parent identifier of a child process.

 

The function call has no arguments and has the following syntax:

 

Me.Case.ParentProcessId

 

Let us consider a Human Resources Selection Process. The PerformTests Sub-Process is a multiple sub-process that performs different tests in order to determine the candidate's skill level for a given position

 

CurrentCaseInfo2

 

All tests must be passed for the candidate to advance in the process. Otherwise, the job application will be rejected.

The rejection will execute the Cancel Selection Event in the parent process, from within the Sub-Process' Cancel Selection Process Task.

 

CurrentCaseInfo3

 

 

To create this cancellation event, do the following:

 

1. Go to the fourth step of the Bizagi Process Wizard (Business Rules) and select Activity Actions.

Select the Cancel Selection Process Task in the Perform Test Sub-Process and create an On Enter Expression.

 

CurrentCaseInfo4

 

2. Add an Expression module. Include a setEvent function to execute the Cancel Selection Event.

The first parameter of the function is the identifier if the parent process. Retrieve the identifier by calling the ParentProcessId function found in the Current Case Information category.

 

 

CurrentCaseInfo1

 

CHelper.setEvent(Me,Me.Case.ParentProcessId,"CloseSelection",null);

 

Finally save the expression.

 

 

Obtain the Id of the child process (sub-process) in a parent process

You can obtain the identifier of a child process by using the getSubProcessesId function.

This function returns a list with the sub-processes' identifiers of all the related cases.

 

The syntax of this function is as follows.  It takes the Entity context as an input parameter.

 

CHelper.getSubProcessesId(Me)

 

Imagine a Project Administration Process. The necessary activities to complete the project are planned in the Plan Activities Task.

The Perform Activities Sub-Process is launched by each activity planned. Simultaneously a task is enabled for the Project Manager to monitor the progress of each activity.

 

CurrentCaseInfo14

 

The cases related to each instance of the Perform Activities Sub-Process have a private security level (please refer to Case Security); that is, only people who have performed a task within the Sub-Process have access to the case information. However, the development of each activity of the Project must be monitored by an auditor so he/she must have access as well.

 

In order to grant access to the auditor it is necessary to create an expression. This expression will obtain the identifiers of each instance of the Sub-Process to grant the auditor access to each of them. Follow the next steps to create the expression:

 

 

1. Go to the fourth step of the Bizagi Process Wizard (Business Rules) and select Activity Actions.

Select the Monitor Activities Task and create an On Enter Expression. This will execute the expression at the same time the instances of the sub-process are created.

 

CurrentCaseInfo15

 

 

2. Create an Expression module. Obtain the list of associated Sub-Processes into a variable by using the getSubProcessesid function found in the Current case information category.

 

CurrentCaseInfo9

 

 

 

CurrentCaseInfo10

 

3. Obtain the UserId of the auditor. Use the CHelper.GetUsersforRole to retrieve a list of user Ids with a specified Role. As only one person has the Auditor Role we can extract the auditor Id from the position 0 of the list.

 

 

CurrentCaseInfo6

 

 

4. Include a FOR operator to go through the list of Sub-Processes.

 

CurrentCaseInfo11

 

 

5. Obtain the id of each Sub-Process and use it as the first parameter of the CHelper.GrantCaseAccess function. The second parameter of this function will be always the UserId of the auditor. This will grant the auditor access to the information of each Sub-Process.

 

CurrentCaseInfo8

 

var ChildProcesses=CHelper.getSubProcessesId(Me);

var ListofAuditors=CHelper.getUsersForRole("Auditor");

var UserId=ListofAuditors[0];

for(var Records=0; Records < ChildProcesses.Count; Records++)

{

var Case=ChildProcesses[Records];

CHelper.GrantCaseAccess(Case,UserId);

}

 

Finally save the expression.

 

 

Obtain the Ids of sibling Processes from the current Sub-Process’ Parent Process.

You can obtain the identifiers of the sibling Processes (Sub-Processes with the same parent Process) of a specific Process by using the getSiblingProcessesId function.

 

This function returns a list with the Sub-Processes’ identifiers of the current case, which belong to the class of Process (workflow) specified.

 

The syntax of this function is:

CHelper.getSiblingProcessesId(Me,iWfClassId)

 

A Police Department decided to automate the Homicide cases handling Process in Bizagi. In the first Activity of the Process all the information of the homicide is entered. A list of suspects is also created in order to perform the corresponding investigations.

 

The Suspect Investigation Sub-Process is opened for each suspect. As soon as one of the suspects is found responsible for the homicide the other investigations must be canceled and the Process continues to generate the arrest warrant and proceed with the capture.

 

CurrentCaseInfo18

 

A Divergence Gateway is used to evaluate if a suspect was found responsible when the investigation finishes. If so, an expression is executed to cancel the other investigations; otherwise the Sub-Process finishes and the unsolved crime becomes a "cold case".

 

CurrentCaseInfo19

 

Follow the next steps to create the expression that cancels the remaining investigations.

 

1. Go to the fourth step of the Bizagi Process Wizard (Business Rules) and select Activity Actions.

Select the Cancel Active Investigations Task within the Suspect Investigations Sub-Process and create an On Enter Expression.

 

CurrentCaseInfo20

 

2. Add an Expression module. Obtain the list of sibling Sub-Processes (other investigations) and save it in a variable using the getSiblingsProcessesId function found in the Current case information category.

 

CurrentCaseInfo21

 

The parameter of this function is the identifier of the process (workflow class). The Id (iWfClassId) can be found in Bizagi's data base in the WFClass table. We recommend that the person who obtains this Id to have a high technical profile. Do not attempt to open the data base if you have never worked with SQL or Oracle before.

 

CurrentCaseInfo22

 

 

3. Include a FOR operator to go through the list of Sub-Processes.

 

CurrentCaseInfo23

 

 

4. Use the CHelper.AbortProcess function to cancel the other processes. This function receives three parameters:

 

The first parameter is the sentence Me.

The second parameter is the id of the case to be aborted. In this case we obtain the Id of each Sub-Process to be aborted.

The third parameter is a number:

oType 1 if only the process is to be aborted. (This is the case of the present example)

oType 2 If the process and its parent process are to be aborted

oType 3 if only the parent process is to be aborted, NOT the process itself.

 

 

CurrentCaseInfo24

 

//Obtain the Siblings Processes id´s

var SiblingProcesses=CHelper.getSiblingProcessesId(Me,57);

 

//Go through the list

for(var Records=0; Records < SiblingProcesses.Count; Records++)

{

//Obtain Sibling Process id

var Case=SiblingProcesses[Records];

//Abort Sibling Process

CHelper.abortProcess(Me,Case,1);

}

 

Finally save the expression.

 

Evaluate if there are open processes

You can evaluate if there are open processes related to a specific Process by using the thereAreOpenProcesses function.

 

This function returns true when cases are open for the specific case number (otherwise, it returns false).  

 

The syntax of this function is:

CHelper.thereAreOpenProcesses(CaseNumber)

 

Imagine a Project Administration Process. The necessary activities to complete a project are planned in the Plan Activities Task.

The Perform Activities Sub-Process is launched by each activity planned. Simultaneously an activity is enabled for the Project Manager to monitor the progress of each activity.

 

If the Project Manager tries to close the Project when there are pending activities, that is, opened instances of the Perform Activity Sub-Process, a validation must be thrown in order to ensure all the activities are completed before closing the case.

 

 

CurrentCaseInfo14

 

To validate that all the activities have been finished we will use the thereAreOpenProcesses function.

 

1. Go to the fourth step of the Bizagi Process Wizard (Business Rules) and select Activity Actions.

Select the Monitor Activities Task and create an On Exit Expression.

 

 

CurrentCaseInfo15

 

 

2. Add an expression module. Evaluate if there are pending activities by using the thereAreOpenProcesses function found in the Current case information category. Set the Me.Case.CaseNumber function as parameter.

 

3. When there are pending activities, the function thereAreOpenProcesses returns true. Then, a validation must be thrown. Include the message that will be displayed.

 

 

CurrentCaseInfo17_Patch

 

Finally save the expression.

 

if(CHelper.thereAreOpenProcesses(Me.Case.CaseNumber)==true)

{

CHelper.ThrowValidationError("There are pending activities. You cannot close the case");

}

 

 

Obtain the WorkItem of a specific task

You can obtain the WorkItem related to a specific task by using the Me.Case.getWorkItem function. This is especially useful to get or set information of a task from any other task in the process by specifying the task's unique name.

 

This function returns a Work Item object. The syntax is:

 

Me.Case.getWorkItem(TaskName)

 

In a Customer Service Process a timer event is used to remind the case expiration of a request. According to the nature and necessary actions to assist the request, a customer service agent can modify the initial due date. This update can be done from any task of the process by changing the value of an attribute of the data model called DueDate.

 

CHelper77

 

To update the timer duration you can make use of the Me.Case.getWorkItem function

 

Create an expression as an on exit action of the task from where the timer duration can be updated.

 

Use the Me.Case.getWorkItem function using the name of the timer event as a parameter. For this example this name is DueDateReminder.

 

CHelper75

 

Now apply the .EstimatedSolution method over the Work Item object to set the new timer duration.

 

CHelper76

 

//Update the timer duration

Me.Case.getWorkItem("DueDateReminder").EstimatedSolutionDate=<CustomerServiceRequest.DueDate>;

 

 

Assign a task to a specific user

You can assign a task to a specific user using expressions with the Me.Case.assignWorkItem function.

 

The syntax of this function is:

 

Me.Case.assignWorkItem(TaskName, UserId, Replace)

 

The function uses three parameters:

 

TaskName: Unique name of the task to be assigned. This name can be identified in the database.​

UserId: Id of the user to which the task will be allocated.

Replace: Boolean value. If the boolean is true, it will replace all assigned users. If it is false, the user will be added to the assigned users.

 

 

 

An insurance company uses Bizagi to manage its Judicial processes. At the beginning of the process, a lawyer is allocated to perform the process follow-up. Anytime in the process, the Legal affair manager can reallocate this lawyer, to do so, an intermediate event is enabled.

 

Once the Legal affair manager chooses the new lawyer in the event, the activities currently allocated to previous lawyer must be reallocated to the new lawyer.

Suppose these are two activities: Follow up process and Activate conciliation.

To reallocate the lawyer, an expression is defined as an on exit action of the event.

 

1. Go to the fourth step of the Bizagi Process Wizard (Business Rules) and select Activity Actions.

Select the Event from which the new lawyer is selected by the Legal affair manager.

 

 

2. Add an expression module.

Obtain the id of the user to be allocated. In this case, the IdUser of the new lawyer.

 

 

ReassingWorkItem1

 

3. Use the Me.Case.assignWorkItem function to reallocate the tasks to the new lawyer. For this example, suppose the following names belong to these tasks (different from their display names):

Follow up process = "ProcessFollowup"

Activate conciliation = "ActivateConciliation"

 

ReassingWorkItem2

 

 

//Obtain the id of the new lawyer

var UserId=<JudicialProcess.NewLawyer.idUser>;

//Reassign the Follow up process task

Me.Case.assignWorkItem("ProcessFollowup", UserId, true);

//Reassign the Activate conciliation task

Me.Case.assignWorkItem("ActivateConciliation", UserId, true);