<< Click to Display Table of Contents >> Execute events |
The setEvent function is used to execute an available intermediate Event in Bizagi, which has no specific type defined.
For example, it can be used on an expression related to a button to execute an intermediate event in my process. The function can execute events in the active process or in an external process.
To ensure an effective management of transactions and scopes in our system, it is strongly recommended that the SetEvent 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. |
The syntax of this function is:
CHelper.setEvent(Me,Caseid,"Event name",null)
The main parameters of this function are:
•The Caseid: the identification number of the Case in which the Event will be triggered
•The Event Name: the name of the event to be executed
•The first and last parameters (Me and null) are fixed.
The setEvent function is found in the Process category.
Example
Let us take the Help Desk Process as example. Once a case is created, an Event is enabled that allows the case to be closed at any time, as shown in the Process flow below.
The Analyze and Resolve Task contains a button that will close the case automatically if clicked
This button will call the Close Case Event. The Process flow will reach the End Event and the case will be closed.
To configure the case closing Event, follow the next procedure:
1. Go to the form of the Analyze and Resolve Task, include a new button and name it Close Case.
Create an action (from Actions and validations) when the button is clicked, then select execute rule in the Then block.
2. In the argument, click New and then include an Expression module.
Select the setEvent function.
3. Value the parameters of the setEvent function.
The Caseid is obtained using the Me.Case.Id function which returns the ID of the current case.
The Event Name, is CloseCase.
You can verify the name in the Event properties of the Task by going to first step of the Process Wizard.
CHelper.setEvent(Me,Me.Case.Id,"CloseCase",null);
This similarly, with the XML method would be. You can use the Case Number, for example, when you use customized cases, using the <radNumber> tag.
var XML = "<BizAgiWSParam>"
+"<domain>domain</domain>"
+"<userName>Admon</userName>"
+"<Events>"
+"<Event>"
+"<EventData>"
+"<radNumber>" + Me.Case.CaseNumber + "</radNumber>"
+"<eventName>CloseCase</eventName>"
+"</EventData>"
+"<Entities></Entities>"
+"</Event>"
+"</Events>"
+"</BizAgiWSParam>";
CHelper.setEvent(XML);
Or you can use the XML with the case ID using the <idCase> tag.
var XML = "<BizAgiWSParam>"
+"<domain>domain</domain>"
+"<userName>Admon</userName>"
+"<Events>"
+"<Event>"
+"<EventData>"
+"<idCase>" + Me.Case.Id + "</idCase>"
+"<eventName>CloseCase</eventName>"
+"</EventData>"
+"<Entities></Entities>"
+"</Event>"
+"</Events>"
+"</BizAgiWSParam>";
CHelper.setEvent(XML);
Save the expression. When you click the Close Case button from the Work Portal the case will be closed.
Last Updated 4/3/2024 12:39:02 PM