Creatio development guide
PDF
This documentation is valid for Creatio version 7.10.0. We recommend using the newest version of Creatio documentation.

Creating custom [User task] process element

Glossary Item Box

Introduction

It often becomes necessary to perform similar operations repeatedly while working with business processes in bpm'online. The [User task] process element is best suited for these operations. Learn more about the [User task] element in the “[User task] process element” article.

By default, a number of custom user tasks is already available in the system. You can add new user tasks if needed.

The “User task” configuration schema type is used to create new user tasks. The process task partially replicates the logic of the [Script task] process element. However, a user task can be reused in different processes. Any changes to the task will be immediately applied to all processes that have the said task.

Case of creating a user task

Case description

Create a simple process user task that will calculate the sum of two numbers. Use two numbers (specified as task parameters) to calculate the sum.

Case implementation algorithm

1. Create a user task schema

To do this, go to the [Configuration] section of the system designer, select a custom package and on the [Schemas] tab, execute the menu command [Add] - [User Task] (Fig.1).

Fig. 1. Creating a user task schema

A user task designer window will open.

The default values for [Name] and [Title] are "UsrProcessUserTask1" and "User Task 1", respectively.

ATTENTION

If the process task schema is added to a custom package, which is not the current one, you must add the package with the created schema to the dependencies of the current package.

The default package is Custom. Use the [Current package] system setting to view and change the current package.

2. Add task parameters.

On the [Activity] tab of the process task designer, open the context menu on the [Parameters] element to add task result parameters. Execute the [Add] context menu command (Fig. 2).

Fig. 2. Create a process task parameter

 

A new parameter will be added as the result, and its main properties are displayed in Fig. 3.

Fig. 3. Default properties of a user task parameter.

 

Add three parameters to create the process task (main properties are shown in table 1).

Table 1. Main parameters of the created process task

Name Type Description
FirstNumber Integer First number
SecondNumber Integer Second number
SumOfNumbers Integer Sum of numbers

 3. Add task logic

The task logic is set via a script. The task script is a process task parameter which contains the C# program code used to implement the necessary task logic.

Fig. 4. Adding user task logic

To add the task script program code, select the root element of the structure (Fig. 4, 1) then add the program code to the text field of the [Script] property (Fig. 4, 2):

// Performing operations with task parameters
SumOfNumbers = FirstNumber + SecondNumber;
// Indicates that the task script execution was successful.
return true;

The parameters must be addressed directly by name. Return the true value at the end of the script to signal the successful execution of the element and continue the process.

Select the [User task] checkbox (located under the script input field (Fig. 4, 3)) to enable using the custom user task in business processes.

4. Save and publish the schema

After assigning values to necessary properties of the created process task schema, save the schema and then publish it (Fig. 5).

Fig. 5. Saving and publishing a schema

 

You can use the user task to create business processes after successfully publishing the schema.

5. Testing

Create a new business process to test the user task. Learn more about creating business processes in the “How to create business processes” article.

In the process designer, add the [User task] and the [Auto-generated page] elements to the process diagram (Fig. 6).

Fig. 6. Business process diagram.

 

Specify the schema title (see step 1) in the [User task] property of the [User task 1] element (Fig. 7).

Fig. 7. Selecting a custom process task

 

Set the values of the sum parameters on the [Parameters] tab. The [Sum of numbers] parameter value will be overridden by the script (see step 3), so the value entry field for this parameter can be left blank.

Fig. 8. User task parameter values

 

The [Auto-generated page 1] element displays the task result, i.e. parameter sum values of the user task. To display the sum of the parameters, you must first add an integer to the page element collection (Fig. 9), and then set the title of the auto-generated page element (Fig. 10, 1).To set the displayed value, call the value formula dialog by clicking the lightning icon in [Value] field. (Fig.10, 2). 

Fig. 9. Adding page elements

 

 Fig. 10. Page element parameters

 

In the [Formula] dialog box that appears on the [Process Elements] tab, select the [Process task 1 1] element (Fig. 11, 1), and then double-click the [Sum of Numbers] item (Fig. 11, 2). The formula used to calculate the auto-generated page value will be displayed (Fig. 11, 3).

Fig. 11. The [Formula] dialog window

 

Save the formula (Fig. 11, 4) and the added auto-generated page element (Fig. 10, 3).

Run the process (Fig. 6, 2) after saving it (Fig. 6, 1). The message will alert that the process has started. A notification will enable you to display the business process log (Fig. 12).

Fig. 12. Business process start message

 The business process result is shown in Fig. 13.

Note

After changing the parameter values of the custom task, change the currently displayed page in the system before starting the business process again (go to any system section, for example). If you do not leave the auto-generated business process page, it will display the previous result.

Adding process task to the [Process elements] tab

If created custom process task element is planned for regular use, it can be added to the [Process elements] tab in the process designer. To do so, execute the following SQL script in the database:

-- UsrProcessUserTask1 – name of the process task schema.
insert into SysProcessUserTask(SysUserTaskSchemaUId, Caption)
select s.UId, s.Caption from SysSchema s
where s.Name = 'UsrProcessUserTask1’

After restarting (or compilation) the application the element will be displayed on the tab:

Fig. 13. Custom element on the tab [User Task 1]

 

 

© bpm'online 2002-2017.

Did you find this information useful?

How can we improve it?