Skip to main content
Version: 8.0

Run the business process that receives parameters from a client module

Level: intermediate
Example

Add the Receive parameters custom action to the account page and Accounts section list. The action must run the Result parameters custom business process. The action must be active if the account has a primary contact, i. e., the Primary contact field of the account page is filled out. Pass the primary contact of the account to the business process as a parameter. Display the job title and age of the account’s primary contact as resulting parameters in the business process dialog.

1. Implement the Result parameters custom business process

  1. Open the Configuration section and select a custom package to add the business process.

  2. Click AddBusiness process on the section list toolbar.

  3. Fill out the business process properties.

    • Set Title to "Result parameters."
    • Set Code to "UsrParametersProcess."

    Use default values for the other properties.

  4. Add business process parameters.

    View the process parameters values to fil out in the table below.

    Process parameters values

    Title

    Code

    Data type

    Direction

    "Primary contact"

    "ProcessSchemaContactParameter"

    "Unique identifier"

    "Input"

    "Contact age"

    "ProcessContactAge"

    "Integer"

    "Output"

    "Full job title"

    "ProcessFullJob"

    "Text (500 characters)"

    "Output"

  5. Implement data reading.

    1. Add the Read data element to the Process Designer workspace.

    2. Fill out the element properties.

      • Set Which data read mode to use? to "Read the first record in the selection."
      • Set Which object to read data from? to "Contact."
      • Set the filter by the Id column in the How to filter records? property. Set the value of the "Primary contact" incoming parameter as the column value.
  6. Add the values of the outgoing parameters.

    1. Go to the Parameters tab.
    2. Enter "[#Read data.First item of resulting collection.Full job title#]" in the Value field for the Full job title parameter.
    3. Enter "[#Read data.First item of resulting collection.Age#]" in the Value field for the Contact age parameter.
  7. Click Save on the Process Designer’s toolbar.

2. Create a replacing view model schema of the account page

  1. Open the Configuration section and select a custom package to add the schema.

  2. Click AddReplacing view model on the section list toolbar.

  3. Fill out the schema properties.

    • Set Code to "AccountPageV2."
    • Set Title to "Account edit page."
    • Set Parent object to "AccountPageV2."
  4. Add a localizable string that contains the menu item caption.

    1. Click the button in the context menu of the Localizable strings) node.

    2. Fill out the localizable string properties.

      • Set Code to "CallProcessParametersCaption."
      • Set Value to "Recieve parameters."
    3. Click Add to add a localizable string.

  5. Implement the menu item logic.

    Implement the following methods in the methods property:

    • isAccountPrimaryContactSet(). Checks whether the primary contact of the account is filled out and defines the visibility of the menu item.
    • callCustomProcess(). Action handler method. Runs the business process and displays the values of the resulting parameters in the dialog.
    • getActions(). An overloaded base method. Returns the action collection of the replacing page.

    View the source code of the replacing view model schema of the account page below.

    AccountPageV2
    define("AccountPageV2", [], function() { 
    return {
    /* The name of the record page object’s schema. */
    entitySchemaName: "Account",
    /* The methods of the record page’s view model. */
    methods: {
    /* Check the [Primary contact] field of the account is filled out to define the visibility of the menu item. */
    isAccountPrimaryContactSet: function() {
    /* Return true if the primary contact is filled out, return false otherwise. */
    return this.get("PrimaryContact") ? true : false;
    },
    /* Overload the base virtual method that returns the collection of record page actions. */
    getActions: function() {
    /* Call the parent method implementation to retrieve the collection of base page’s initialized actions. */
    var actionMenuItems = this.callParent(arguments);
    /* Add a separator line. */
    actionMenuItems.addItem(this.getActionsMenuItem({
    Type: "Terrasoft.MenuSeparator",
    Caption: ""
    }));
    /* Add a menu item to the action list of the record page. */
    actionMenuItems.addItem(this.getActionsMenuItem({
    /* Bind the menu item caption to the localizable schema string. */
    "Caption": {
    bindTo: "Resources.Strings.CallProcessParametersCaption"
    },
    /* Bind the action handler method. */
    "Tag": "callCustomProcess",
    /* Bind the property of the menu item visibility to the value returned by the isAccountPrimaryContactSet() method. */
    "Visible": {
    bindTo: "isAccountPrimaryContactSet"
    }
    }));
    return actionMenuItems;
    },
    /* The action handler method. Run the business process and display the values of the resulting parameters in the dialog. */
    callCustomProcess: function() {
    /* Receive the ID of the account’s primary contact. */
    var contactParameter = this.get("PrimaryContact");
    /* Create an object of the Terrasoft.RunProcessRequest class. */
    const runProcessRequest = Ext.create("Terrasoft.RunProcessRequest", {
    /* The process schema code. */
    "schemaName": "UsrParametersProcess",
    /* The ID of the process diagram. */
    "schemaUId": "9ff60fa7-314e-4b9e-b9fc-57f91b8b2e21",
    /* Incoming process parameters. */
    "parameterValues": {
    "ProcessSchemaContactParameter": contactParameter.value
    },
    /* Outgoing process parameters. */
    "resultParameterNames": [
    "ProcessContactAge",
    "ProcessFullJob"
    ]
    });
    /* Run the custom business process. */
    runProcessRequest.execute(function(response) {
    /* If the process is executed successfully, display the values of the resulting parameters in the dialog. */
    if (response.isSuccess()) {
    var job = response.resultParameterValues["ProcessFullJob"];
    var age = response.resultParameterValues["ProcessContactAge"];
    Terrasoft.showInformation("Full job title: " + job + " Age: " + age);
    }
    }, this);
    }
    }
    };
    });
  6. Click Save on the Module Designer’s toolbar.

Creatio does not display the custom account page action in combined mode.

3. Create a replacing view model schema of the section page

  1. Open the Configuration section and select a custom package to add the schema.

  2. Click AddReplacing view model on the section list toolbar.

  3. Fill out the schema properties.

    • Set Code to "AccountSectionV2."
    • Set Title to "Accounts section."
    • Set Parent object to "AccountSectionV2."
  4. Add a localizable string that contains the menu item caption. To do this, take step 4 of the procedure to create a replacing view model schema of the account page.

  5. Implement the menu item behavior. To do this, implement the isAccountPrimaryContactSet() method in the methods property. The method checks whether the primary contact of the account is filled out and defines the visibility of the menu item.

    View the source code of the replacing view model schema of the section page below.

    AccountSectionV2
    define("AccountSectionV2", [], function() { 
    return {
    /* The name of the section page schema. */
    entitySchemaName: "Account",
    /* The methods of the section page’s view model. */
    methods: {
    /* Check whether the [Primary contact] field of the account is filled out. */
    isAccountPrimaryContactSet: function() {
    /* Define the active record. */
    var activeRowId = this.get("ActiveRow");
    if (!activeRowId) {
    return false;
    }
    /* Retrieve the data collection of the section list’s list view. Retrieve the model of the account by the specified primary column value. */
    var selectedAccount = this.get("GridData").get(activeRowId);
    if (selectedAccount) {
    /* Receive the [Primary contact] model property. */
    var selectedPrimaryContact = selectedAccount.get("PrimaryContact");
    /* Return true if the primary contact is filled out, return false otherwise. */
    return selectedPrimaryContact ? true : false;
    }
    return false;
    }
    }
    };
    });
  6. Click Save on the Module Designer’s toolbar.

Outcome of the example

To view the outcome of the example

  1. Refresh the Accounts section page.
  2. Open an account page, for example, Vertigo Systems.

As a result, Creatio will add the Receive parameters action to the account page.

Click the Receive parameters action to run the Result parameters business process. The primary contact of the account will be passed to the business process as a parameter. The job title and age of the account’s primary contact will be displayed as the resulting parameters of the business process.

The action will be active if the account has a primary contact, i. e., the Primary contact field of the account page is filled out. For example, the action is inactive for the Wilson & Young account.

The Receive parameters custom action will be displayed on the Accounts section page and active for the selected account that has a primary contact.


Resources

Package with example implementation