Example: Conditional Start Events With Global Data Expression Syntax

Follow examples of how to configure Conditional Start Events with Global Data Expression Syntax.

Overview

Conditional events are triggered when an external condition is enabled or disabled. The data that can be used to assert conditions can be divided into two groups:

  • Request Data, which is all the request’s variables.

  • Global Data, which is all the data external to a request such as the server time, user data, or other requests data. ProcessMaker publishes some functions with the Symfony Formal Expression that allow access to the most relevant global data. For more information about these functions, see Global Data Expression Syntax.

In Intermediate Conditional Event elements we can use both Request and Global Data. Conditional Start Event elements use Global Data only.

Global Data Functions Examples

The following examples use Global Data Expression Syntax functions in the Condition setting of the Conditional Start Events configuration.

date

  • Start a Request when the current year is 2022: date(“Y”) == 2022

  • Start a Request every time that the current minute is 2: date("i") % 2 == 0

env

  • Start a Request when the environment variable API_TIMEOUT is set to a time that is greater than 30000: env(“API_TIMEOUT”) > 30000

  • Start a Request when the email server has an SMTP configuration: env(“MAIL_DRIVER”) == “smtp”

getActiveTaskAt (node_id, requestId)

  • Start a Request when the third node and the first Request of a Process is triggered: getActiveTaskAt('node_3', 1) != null

  • The syntax allows you to navigate through attributes using the dot notation. Then, start a Request when the Task with ID node_3of Request 1 is assigned to a user from Argentina: getActiveTaskAt('node_3',1).user.country == “AR”

lowercase

  • Start a Request when user 1 has firstname test: lowercase(user(1).firstname) == “test”

process(process_id)

  • Start a Request when a Process ID 86 is present in the database: process(86) != null

  • Start a Request if the Process 86 description is set to Outage: process(86).description == “Outage”

  • Access the Process's Request information. For example, start a Request when Process 86 has one or more Requests: process(86).requests.count()>0

  • Start a Request when the last added Request is assigned to a user with ID 2: process(86).requests.last().user_id == 2

request(request_id)

  • Start a Request when the Request 1000 is created: request(1000) !=  null

  • All elements of Request data can be accessed using arrays. For example, start a Request when Request 1 stock is less than 100: request(1).data['stock'] < 100

  • Start a Request when Request 1 has a user with username admin assigned to it: request(1).data[”_user”][”username”] == “admin”

  • Start a Request when Request 1 is created later than the first day of 2023: request(1).created_at > '2023-01-01'

uppercase

  • Start a Request when user 1 has firstname TEST: uppercase(user(1).firstname) == “TEST”

user(user_id)

  • Start a Request when user 1 changes its username to anonymous: user(1).username == “anonymous”

  • Syntax allows the use of regular expressions. For example, starts a Request when the user 1 firstname starts with Admin: user(1).firstname matches "/^Admin*/" == 1