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

How to run a process from client module

Glossary Item Box

Running process from configuration schema code

In order to run a business process in JavaScript code, take the following actions:

  1. Connect ProcessModuleUtilities module to a module of the page, from which the service is called. This module provides a convenient interface for execution of queries to the ProcessEngineService.svc service.
  2. Call executeProcess(args) method from ProcessModuleUtilities module by transferring args object with such properties (table 1):

Table 1. — args object properties

Property Description
sysProcessName A name of called process (this property is optional if sysprocessid is determined).
sysProcessId A unique identifier of called process (this property is optional if sysprocesname is determined).
parameters

An object, properties of which are represented by input parameters of called process.

 

Example of process running from configuration schema

Add actions, through which the "Holding a meeting" business process will run, to the account edit page. The main account contact will be transferred to the business process as a parameter.

Case implementation algorithm

1. Create the "Holding a meeting" user business process

The example uses a business process, creation of which is described in the Designing a linear process.

Once a business process is created, add the ContractParameter input parameter, in the properties of which the Unique identifier identifier is specified in the [Data type] field (figure 1).

Figure 1. — Adding of input parameter

Then fill in the [Contact] field with a given process input parameter in the properties of the first actions of the [Call to customer] process (Figure 2).

Figure 2. — Parameter transferring to the process item

2. Create replacing account edit page and add action to it

The process of adding an action to an edit page is described in the Adding an action to the edit page article.

Add CallProcessCaption localizable string with action title, for example, "Schedule a meeting" to the schema of replacing account edit page module.

Connect ProcessModuleUtilities module in declaration of edit page module as a dependency.

3. Add action handler and call process running method in it

To run a process, use executeProcess method of ProcessModuleUtilities module and transfer the object with the following properties into it: name of created business process and object with initialized input parameters for the process.

Source code of replacing module of edit page is represented below.

define("AccountPageV2", ["ProcessModuleUtilities"],
    function (ProcessModuleUtilities) {
        return {
            // Name of the schema of edit page object.
            entitySchemaName: "Account",
            details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
            // Collection of methods of view model of edit page.
            methods: {
                // The method verifies whether the [Main contact] field of the page is completed.
                isAccountPrimaryContactSet: function () {
                    return this.get("PrimaryContact") ? true : false;
                },
                 // Overridding of basic virtual method that returns collection of edit page actions
                getActions: function () {
                    // Parent implementation of the method is called for 
                    // for getting collection of initialized actions of basic page
                     var actionMenuItems = this.callParent(arguments);
                    // Adding separator line for visual separation of user action from the list of 
                    // actions of basic page.
                    actionMenuItems.addItem(this.getActionsMenuItem({
                        Type: "Terrasoft.MenuSeparator",
                        Caption: ""
                    }));
                    // Adding [Schedule meeting] menu item to the lists of actions of edit page.
                    actionMenuItems.addItem(this.getActionsMenuItem({
                        // Binding of menu item title to localizable schema string.
                        "Caption": { bindTo: "Resources.Strings.CallProcessCaption" },
                        // Binding of action handler method.
                        "Tag": "callCustomProcess",
                         // Binding of visibility property of menu item to the value that returns isAcciuntPrimaryContactSet method.
                        "Visible": { bindTo: "isAccountPrimaryContactSet" }
                    }));
                    return actionMenuItems;
                },
                // Method -handler of action selection.
                callCustomProcess: function () {
                    // Getting identifier of account main contact.
                    var contactParameter = this.get("PrimaryContact").value;
                    // The object that will be transferred to execureProcess method as an argument.
                    var args = {
                        // Name of the process that should be run.
                        sysProcessName: "CustomProcess",
                        // Object with the value of ContractParameter input parameter for CustomProcess parameter.
                        parameters: {
                            ContactParameter: contactParameter
                        }
                    };
                    // Running of user business process.
                    ProcessModuleUtilities.executeProcess(args);
                }
            }
        };
    });

4. Save schema in the configuration

Case execution result is shown on Fig. 3 and Fig. 4.

Figure 3. — Calling of business process upon action on the edit page 

Figure 4. — Business process running result. Transferring of parameter for account edit page to business process

 

 

© bpm'online 2002-2017.

Did you find this information useful?

How can we improve it?