Create a new case

<< Click to Display Table of Contents >>

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

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 three 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.

 

 

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.NewCase(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.NewCase function to create the new case.

This function is found under the Process category of functions.

 

 

NewCase8

 

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.

 

NewCase5

 

 

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

 

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.NewCase(sXML)

}