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

Creating custom [User task] process element

Glossary Item Box

Introduction

It is often necessary to perform similar operations repeatedly while working with business processes in Creatio. 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 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 contain the mentioned task.

Case description

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

Source code

You can download the package with case implementation using the following link.

Case implementation algorithm

1. Creating a user task schema

Go to the [Configuration] section of the system designer, select a custom package and execute the menu command [Add] - [User Task] on the [Schemas] tab (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.

2. Adding 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. Creating a process task parameter

A new parameter will be added as a result, 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. Adding 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) and 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. Saving and publishing the schema

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

Fig. 5. Saving and publishing the 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 [Which user task to perform?] property of the [User task 1] element (Fig. 7).

Fig. 7. Selecting a custom process task

Set the values of the parameters whose sum will be calculated (Fig. 8). The [Sum of numbers] parameter value will be determined by the script (see step 3), so the value entry field for this parameter can be left unpopulated.

Fig. 8. User task parameter values

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

Fig. 9. Adding page elements

Fig. 10. Page element parameters

In the [Formula] dialog window that appears on the [Process Elements] tab, select the [User task 1] element (Fig. 11, 1) and double-click the [Sum of Numbers] element parameter (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.

Fig. 13. Result of the business process execution.

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

Adding the user process task to the [Process elements] tab

If the created user 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. 14).

Fig. 14. User task element on the tab

Possible issues

If the parameters tab of the created element is not displayed (see Fig. 8), specify the UserTaskPropertiesPage ("User task element properties edit page") schema in the "Parameters edit page 7.x" property (see Fig. 15).

Fig. 15. — "Parameters edit page 7.x" property

 

© Creatio 2002-2020.

Did you find this information useful?

How can we improve it?