Workflow Activities
The Workflow supports a set of activities of various types to configure a process that fits your needs.
Find more about the functionality in the Workflow Editor.
This article describes out-of-the-box activities. To learn how to create your own workflow activities, see the Custom Activities article.
Available activities:
- Run Script activity
- Join activity
- Set Values activity
- Record Generator activity
- Create Event activity
- Wait Condition activity
- If activity
- Switch activity
- User-approval activity
- Subflow activity
- Timer activity
To define variables in your activities via the agent interface, if necessary, complete the steps below:
- Navigate to Workflow → Activities.
- Open the activity record you need to edit or click New to create a new activity.
- Fill in the fields.
- Click Save or Save and exit to apply the changes.
See Create Workflows article to learn more.
Activity states
The activity state tells the workflow engine what to do with the activity. The states listed below are standard for all the types of activities implemented in SimpleOne.
Navigate to Workflow → Workflow Executing Activity to see the states of activities in published workflows.
Activities States
State | Description |
---|---|
Running | The workflow engine has started executing the activity. |
Waiting | The workflow engine ignores the activity until a specific event fires. Then it continues processing. |
Finished | The activity is finished. You can see the result value of the activity. |
Canceled | The activity (or the workflow containing it) is canceled. |
Error | A JavaScript error occurred. Review the Script Log (sys_log_script) for details. |
Basic activities
Begin activity
This activity is initial and appears in a newly created workflow. It is a logical start of every workflow.
End activity
This activity, along with the Begin activity, is initial and appears in a newly created workflow. It is a logical conclusion of every workflow.
Utilities
The activities included in this category execute scripts, change and update records.
Run Script activity
The Run Script activity executes the defined script.
Activity fields
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Run script | N | Specify the script to execute. |
Description | N | Add a brief description of the activity. |
This activity type causes the update of the current target record after the execution. The activity logic is defined by the Immediately value in the When to run field within the Workflow Activity Type (wf_activity_type) table.
Also, the Immediately option and the related activity behavior allows to avoid using current.update() within the Run script to update records.
Join activity
The Join activity combines several activity exit transitions, so that they turn into one transition. This activity is useful for synchronizing several activities, so that the next activity does not start until the previous ones are finished.
In the example below, the Join activity waits for the results of processing of the If, Subflow, and Wait activities. If all three transitions from these activities lead to the Join activity, the Complete exit that leads to another activity named Insert is taken. If one of the activities bypasses the Join activity (in this case, it is the No exit of the If activity), then the Incomplete exit is taken.
Never join multiple exits from an activity to a single Join activity, otherwise, the Join activity works incorrectly and never selects the Complete transition.
In the example below, both exits from the If activity lead to the Join activity. Even though the condition of the If activity is met, the Join activity selects the Incomplete exit as the No exit from the If activity is inactive.
How to use the Join activity
- From the left side menu, open the Utilities tab and drag the Join activity onto the canvas.
- Connect the exits of the activities you need to join with the Join activity.
- Create transitions from the Join activity exits (Complete and Incomplete) to the next activities.
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Description | N | Add a brief description for the activity. |
Activity fields
Result | Description |
---|---|
Complete | This exit is taken when all joined activities have finished execution and proceeded to this activity. |
Incomplete | This exit is taken when all joined activities have finished execution, but at least one of them has not proceeded to this activity that is, another path is taken to bypass the Join activity. Example: In this case, the If activity bypasses the Join activity; therefore, the Incomplete exit is taken. |
Set Values activity
The Set Values activity sets specific values to the current record. These values determine the activity behavior when the workflow freezes or ends.
This activity type causes the update of the current target record after its execution. The activity logic is defined by the Immediately value in the When to run field within the Workflow Activity Type (wf_activity_type) table.
Activity fields
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Description | N | Add a brief description of the activity. |
Table | Y | A table to be affected by this activity. This field is populated automatically. |
Set values | N | Select the field to change its value when the workflow pauses or ends, and define the new value. Click the leftmost field to open the drop-down list with the available fields. Click the rightmost field to open the drop-down list or enter the value (depending on the type of the selected field). |
Record Generator activity
The Record Generator activity creates records in any table extending from the Task table.
Activity fields
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Description | N | Add a brief description of the activity. |
Task type | Y | Select the task type. You can make a selection from the corresponding task table. |
Task values from | N | Select a source of values for the task to be created. Available options:
|
Set values | N | Specify an existing template related to the selected task table. This field appears when the Task values from field value is equal to Values. |
Task template | Y | Specify an existing template related to the selected task table. This field appears when the Task values from field value is equal to Template. |
Wait for condition complete | N | Select this checkbox to display Completion conditions. When selected, the conditions are mandatory for completing the task. |
Completion conditions | Y | Specify conditions for the created task. The process will proceed to the next activity only when the task meets all conditions. The field is displayed when the Wait for condition complete checkbox is selected. |
Advanced | N | Select this checkbox to specify a script to execute. |
Script | N | Set values for the task in this script. Use the variable 'new_task' when setting additional values. The script runs after the task values are set (defined in the Task template or Set values fields). This field is displayed when the Advanced checkbox is selected. |
new_task.parent_id = current.sys_id;
new_task.caller = current.getValue('caller');
- If both Completion conditions and Script are specified, then all of them must be executed successfully to proceed to the next activity.
- Ensure that all mandatory fields are populated when using this activity; otherwise, execution of the workflow will stop.
Create Event activity
The Create Event activity puts an event from the Event Register (sys_event_register) table in a queue. Later, this event can execute specific scripts or send notifications. When the Create Event action runs, a new event record is created in the Event (sys_event) table.
See the System Events article to learn more.
Activity fields
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Event register | Y | Select the event instance based on which the activity creates events. All the event instances (or event registers) are listed in the Event Registers (sys_event_register) table. |
Param 1 ... Param 5 | N | Specify the event parameter. If this parameter is a string value, enclose it in quotes. You can use the defined parameters in records related to the system event:
|
Description | N | Add a brief description of the activity. |
Conditions
The activities included in this category set conditions to continue the processing and define further transition of the workflow. The selected transition depends on the conditions set and the activity outcome.
Wait Condition activity
The Wait Condition activity pauses the workflow until the defined conditions are met. The activity checks if the record meets the conditions after every record update.
Activity fields
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Description | N | Add a brief description of the activity. |
Table | N | A table to be affected by this activity. This field is populated automatically. |
Condition | Y | Define the conditions mandatory for proceeding with the Yes transition. |
Advanced | N | Select this checkbox to specify a script to execute. |
Script | N | Specify a script that pauses the workflow at this activity until this script returns true. The result of the script execution will be added with the AND operator to the results of the Condition specified. This field appears when the Advanced checkbox is selected. |
const isUserManager =
ss.hasRole('process_manager'); // true or false
return isUserManager;
If both Condition and Script are specified, then both of them must execute successfully to transition to the next activity. The workflow will stay paused until the Condition is met and the Script returns true.
If activity
This activity checks a condition to determine if a Yes or No transition should be taken.
If both the Condition and Advanced checkboxes are selected, then they both must be evaluated for this activity to proceed to the Yes transition; otherwise, the No transition is taken.
Activity fields
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Description | N | Add a brief description of the activity. |
Table | Y | A table to be affected by this activity. This field is populated automatically. |
Condition | Y | Specify a condition to meet in order to proceed with the Yes transition. An empty condition always returns true. |
Advanced | N | Select this checkbox to specify a script to execute. |
Script | N | Specify a script to execute. If the script is executed, the result of the script will be added with the AND operator to the results of the Condition specified. To proceed with the Yes transition, the script should return the true value. This field is displayed when the Advanced checkbox is selected. |
const uc = new SimpleUserCriteria();
const isUserLocal =
uc.userAcceptanceByCriteria(ss.getUserID(), '165470191717512124'); // true or false
return isUserLocal;
Switch activity
The Switch activity manages transitions by checking the field values against the defined case values (one or more). This activity works like the switch statement.
The activity checks against conditions specified in the Column field or in manually defined exits and, based on the outcome, selects the next transition.
Activity fields
Field | Mandatory | Description |
---|---|---|
Table | N | A table to be affected by this activity. This field is populated automatically. |
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Type | Y | Select the source of the exit options for this activity. The workflow will perform checks against these conditions. Available options:
|
Column | Y | Specify a column containing options for the condition. These options will become exits of the activity. This field appears when the Field option is selected in the Type field. You can change the conditions of the exits or add new conditions by editing them. |
In the example below, the Switch activity takes options from the Type field:
To create additional exits, perform the following steps:
- Right-click the Switch activity and select Add exit.
- Double-click the exit to open the exit form fields.
- Fill in the fields.
- Click Save.
- Repeat to add more exits if needed.
Activity exit fields
Field | Mandatory | Description |
---|---|---|
Name | N | The option name. Specify the name If the Type field is set to Custom. If the Type field is set to Field, the name is taken from the Column. |
Table | N | The table to be affected by this activity. This field is populated automatically. |
Activity | Y | This field is populated automatically and contains an activity related to the exit. |
Description | N | Add a brief description of the activity exit. |
Condition | Y | Define the conditions that are mandatory for the specified transition. |
Advanced | N | Select this checkbox to specify a script to execute. |
Script | Y | Add a script to execute. If specified, the workflow is paused at this activity until this script returns true. This field appears when the Advanced checkbox is selected. |
- If both Condition and Script are specified, then both of them must be executed successfully to proceed to the next activity. The workflow will stay paused until the Condition is met and the Script returns true.
- In case of the Switch activity, every exit can be configured with the scripts. So the Advanced checkbox appears only when the activity has more than one exit. The checkbox appears only on the forms.
Approvals
With the User-approval activity, configure the approval processing: creating approvals, setting approval rules and conditions.
User-approval activity
The activity evaluates the result depending on the following factors:
- the decision made by the approvers.
- the conditions specified in the Approved When or Approval Conditions and Reject Conditions fields.
- (optional) the conditions specified in scripts.
The activity can be completed with one of two results: Approved or Rejected.
Activity fields
- General
- Mandatory Participants
- Non-mandatory Participants
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Description | N | Add a brief description of the activity. It is displayed in the activity block on the canvas. |
Table | Y | A table to be affected by this activity. This field is populated automatically. |
Run сonditions | N | Specify the conditions to be met for generating approvals. If these conditions are not met, the workflow skips the activity. In this case, the Approved exit is taken. |
Approval type | N | Specify the approval type to define the conditions of the activity exits. Available options:
|
Non-mandatory participants | N | Select this checkbox to add the participants who are not required to vote. When this checkbox is selected, the Non-mandatory Participants tab appears. |
Field | Mandatory | Description |
---|---|---|
Employees | N | Select the responsible users. They will receive the approval tickets to make a decision. |
Groups | N | Select the responsible groups. Users included in this group will receive the approval tickets to make a decision. |
Roles | N | Select the roles whose owners will receive the approval tickets to make a decision. |
Advanced | N | Select this checkbox to specify a script to execute. |
Mandatory participant script | N | If the Advanced checkbox is selected, this script is called to determine if any additional approvals should be created. The script is intended to set the answer variable to a comma-separated list of user IDs to add as approvers. This field appears when the Advanced checkbox is selected. |
Approved when | N | Define the approval logic. Available choice options:
|
Approval script | N | Provide a script to determine the approval condition. The script in the example below verifies if at least one member of each approval group has taken a positive decision. In this case, the approval result is considered positive (Approved). This field appears when the Approved when field is set to Condition based on script. |
Approval conditions | Y | Specify the conditions to be met for the Approved exit. If there is more than one condition, they are checked one after another. This field appears when the Approval type is set to Manual. |
Reject conditions | Y | Specify the conditions to be met for the Rejected exit. If there is more than one condition, they are checked one after another. This field appears when the Approval type is set to Manual. |
Mandatory participant script
The code example below implements the following logic:
- Checks groups of the current caller.
- Checks the value of the Responsible attribute of these groups.
- If the responsible group is found, then their user ID is added to the answer array.
const caller = current.getValue('caller');
const callerGroup = new SimpleRecord('sys_user_group');
callerGroup.addQuery('user_id', сaller);
callerGroup.selectAttributes('group_id');
callerGroup.query();
while (callerGroup.next()) {
if (callerGroups.group_id.getValue('responsible')) {
answer = callerGroups.group_id.getValue('responsible');
}
}
You can pass values to the answer variable either as a string or as an array, for example:
answer = ['100000000000000001', '160017550418345219', '159974538715046822'] answer='100000000000000001,160017550418345219,159974538715046822'
Approval script
(() => {
let isFirstGroupApprove = false;
let isSecondGroupApprove = false;
const docID = ss.getDocIdByIds(current.sys_db_table_id, current.sys_id);
const rejectedApp = new SimpleRecord('sys_approval');
rejectedApp.addQuery('item', docID);
rejectedApp.addQuery('state', 'rejected');
rejectedApp.setLimit(1);
rejectedApp.selectAttributes(['sys_id']);
rejectedApp.query();
if (rejectedApp.next()) { // One of tickets rejected
answer = 'rejected';
}
const approvedApp = new SimpleRecord('sys_approval');
approvedApp.addQuery('item', docID);
approvedApp.addQuery('state', 'approved');
approvedApp.selectAttributes(['approver_id']);
approvedApp.query();
const uc = new SimpleUserCriteria();
while (approvedApp.next()) {
let approver = approvedApp.getValue('approver_id');
if (!isFirstGroupApprove) {
isFirstGroupApprove = uc.userAcceptanceByCriteria(approver, '167416106197358457'); // First Group Member
}
if (!isSecondGroupApprove) {
isSecondGroupApprove = uc.userAcceptanceByCriteria(approver, '167416108994075219'); // Second Group Member
}
}
if (isFirstGroupApprove && isSecondGroupApprove) {
return 'approved';
} else {
return 'waiting';
}
}
)()
This tab appears when the Non-mandatory participants checkbox is selected.
Field | Mandatory | Description |
---|---|---|
Employees | N | Select responsible users from the Employee list. They will receive the approvals and make their decisions. Yet, their approval is not mandatory. |
Groups | N | Select responsible groups. Users included in this group will receive the approvals and make their decisions. Yet, their approval is not mandatory. |
Roles | N | Select roles whose owners will receive the approvals and make their decisions. Yet, their approval is not mandatory. |
Advanced | N | Select this checkbox to specify a Non-mandatory participant script to execute. |
Non-mandatory participant script | N | This script is called to determine if any additional approvals need to be created. The script is intended to set the answer variable to a comma-separated list of user IDs to add as approvers. See an example and clarifications in the Mandatory Participants tab. This field appears when the Advanced checkbox is selected. |
Consider non-mandatory participants | N | Select this checkbox to allow non-mandatory participants to vote in approval tickets. |
Subflows
Use the Subflow activity for complex workflows that include other processes.
Subflow activity
The Subflow activity performs an existing workflow as part of the current workflow.
Activity fields
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Workflow | Y | Select a published workflow to be performed by the activity. |
Description | N | Add a brief description for the activity. |
When a Subflow block starts, a workflow context is created for the current record. Until the context is finished, another Subflow block with the same workflow cannot start, because only one workflow context can exist for the current record at a time.
For example, the Subflow block related to the "Request 2nd phase" workflow is configured in the main workflow. After the main workflow starts, the "Request 2nd phase" subflow starts too. The execution context of the subflow is paused. If the main workflow attempts to run the "Request 2nd phase" subflow again, the subflow is created in a canceled state.
Timers
The Timer activity pauses the workflow. This activity is useful when a process requires waiting for a certain period.
Timer activity
The Timer activity defines a period of time when the current workflow does not run. The logic is the following:
- If the workflow context is not finished and the block following the Timer block has the Finished state – the block processing is restarted.
- If the workflow context is not finished and the block following the Timer block has the Waiting state – the block processing is not restarted.
- If the workflow context at the moment of running of the Timer block is finished – processing of the block following the Timer block is not started.
Activity fields
- General
- Schedule
Field | Mandatory | Description |
---|---|---|
Name | N | Specify the activity name. A good practice is to make the name descriptive for clarity. |
Description | N | Add a brief description of the activity. |
Timer, based on | Y | Select the way the timer duration is calculated. Available options:
|
Duration | Y | Specify how long to wait before processing in days, hours, minutes and seconds to wait before proceeding to the next activity. This field appears when the A user specified duration option is selected in the Timer, based on field. |
Script | Y | Specify the script that implements the duration calculation logic. Use the SimpleOne API methods. This field appears when the Script option is selected in the Timer, based on field. |
Field | Mandatory | Description |
---|---|---|
Timezone, based on | N | Specify a timezone source for this activity. Available options:
|
Timezone | Y | Select a timezone from the list. This field appears when the Timezone, based on option is set to A specific time zone. |
Schedule, based on | N | Specify a schedule source for this activity. Available options:
|
Schedule | Y | Select a schedule from the list. This field appears when the Timezone, based on option is set to A specific schedule. |