Create a new case

<< Click to Display Table of Contents >>

Navigation:  Low-code Process Automation > Studio Cloud - Authoring environment > Bizagi Studio > Process wizard > Business Rules > Business Rules examples > Cases and activities >

Create a new case

You can create new cases from expressions using the CHelper.NewCase function. According to your needs, this function can be used in two different ways:

 

To create a new case defining the creator user

To create a new case with business information

 

Below you will find examples of how to use this function for each of the previous purposes.

 

note_pin

To ensure an effective management of transactions and scopes in our system, it is strongly recommended that the NewCase method must be used as the first action in asynchronous automatic activities. This will separate the operations of the involved cases, promoting independence in flow control and its information.

 

Creating a new case defining the creator user

To create a new case defining the case creator user, use the CHelper.NewCaseByUser function with the following syntax:

 

CHelper.NewCaseByUser(idUser,WFClassName)

 

The parameters of this function are:

idUser: id of the user to be set as case creator.

WFClassName: Name of the Workflow to be created. To obtain this parameter please refer to How to obtain wfClassName.

 

Example

In a Help Desk process an agent receives a analyzes a support ticket in the Analyze and resolve task. In some situations, a change in technological resources might be required to solve it. Therefore, a new case of the Change management process should be created at the end of the ticket analysis. The current Help Desk agent must be defined as the case creator of that case.

 

To create a new case of the Change management process from the Help Desk Process using an expression follow the steps below:

 

1. Go to the fourth step of the Bizagi Process Wizard and select Activity Actions.

Click the Analyze and resolve task and create an Expression as an On exit action.

 

2. Add an expression module. Evaluate if a new case of Change management must be created.

 

NewCase2

 

3. Obtain the user id of the current Help Desk Agent using the Me.Case.WorkingCredential.UserId function.

 

NewCase7

 

4. Use the CHelper.NewCaseByUser function to create the new case.

This function is found under the Process category of functions.

 

NewCase11

 

5. Use the id of the Help Desk Agent as the first parameter of the function.

For the second parameter, assume that the Class Name of the Change Management process is equal to ChangeManagement.

 

NewCase12

 

if (<Ticket.RequiresChangeManagement>==true)

{

var AgentId=Me.Case.WorkingCredential.UserId;

CHelper.NewCaseByUser(AgentId,"ChangeManagement");

}

 

Creating a new case with business information

This function creates a new case based on the information provided in the input parameter (string XML). In the input parameter it is possible to include data about the creator and business information for the case.

This function also returns a string with the information about the state of the case like errors during the creation, activities, events and other information.

 

 

To create a new case defining specific business information  use the CHelper.NewCase function with the following syntax:

 

CHelper.NewCase(XML)

 

The parameter of this function is an XML containing the business information. This XML must follow the next structure:

 

<BizAgiWSParam> //start the xml

<domain>domain</domain> //domain of the user that will create the case

<userName>User</userName> //user that will create the case

<Cases><Case><Process>ChangeManagement</Process> //process name

<Entities> //start of the business information

<ProcessEntity> //name of the process entity

<Attribute>AttributeValue</Attribute> //business information

</ProcessEntity></Entities></Case></Cases></BizAgiWSParam>//close the xml

 

note_pin

When sharing processes (generating a .btex file) with global rules that reference multiple processes, make sure that you include all of them in the generated package.

 

Example

In a Help Desk process an agent receives a analyzes a support ticket in the Analyze and resolve task. In some situations a change in technological resources might be required to solve it. Therefore, a new case of the Change management process should be created at the end of the ticket analysis. The current Help Desk agent must be defined as the case creator of that case and the number of the ticket associated to the Change Management process must be the current Ticket number.

 

To create a new case of the Change management process from the Help Desk Process using an expression follow the steps below:

 

1. Go to the fourth step of the Bizagi Process Wizard and select Activity Actions.

Click the Analyze and resolve task and create an Expression as an On exit action.

 

2. Add an expression module. Evaluate if a new case of Change management must be created.

 

NewCase2

 

3. Build a string following a XML structure. Note how the business information is entered.

 

NewCase9

 

4. Use the CHelper.NewCase function and use the XML string as parameter to create the new case.

This function is found under the Process category of functions.

 

NewCase10

 

if (<Ticket.RequiresChangeManagement>==true)

{

var sXML ="<BizAgiWSParam>"; //start the xml document

sXML += "<domain>domain</domain>"; //domain of the user that will create the case

sXML += "<userName>HelpDeskAgent</userName>"; //user that will create the case

sXML += "<Cases><Case><Process>ChangeManagement</Process>"; //process name

sXML += "<Entities>"; //start of the business information

sXML += "<ChangeRequest>"; //name of the process entity

sXML += "<AssociatedTicket>" + Me.Case.CaseNumber + "</AssociatedTicket>"; //business information <attribute>value</attribute>

sXML += "</ChangeRequest></Entities></Case></Cases></BizAgiWSParam>"; //close the xml document

 

CHelper.usingXpath("AssociatedTicket");

CHelper.NewCase(sXML);

}

 

The function prior to the CHelper.NewCase function, the CHelper.UsingXpath function allows to detect the attributes within the XML. To know more about the CHelper.UsingXpath function, click here.


Last Updated 4/3/2024 12:38:11 PM