Skip to main content

Workflow Step - Expression: Conditions, Duration

Conditions expressions

Execute only on Rejected status

var statusId='${status.id}';
return statusId==='5W4yldg4vR3XcAZy5L18';

status is a key for Select type attribute orientated for 'Lookup to object type'=Status. It will also work without exposing the attribute on the form as status is system attribute key.

'5W4yldg4vR3XcAZy5L18' is the text value for Id of Rejected status.

The step with the defined above Condition expression will be TRIGGERED (EXECUTED) only in the case, the document status will be set as Rejected. Otherwise such step will be skipped while processing.

So typically such conditions will appear only for the steps which have to be executed in alternative return processing path of workflow, in the case the document has been rejected previously.

Execute on 1 of a few statuses

This is the extension variant of the previous example. Additional 2 statuses are taken into the account: Pending ('SqqdcjE6DrQkeLpHIIbm') and Refused ('30LQPgRAPWUMgQd1ZyWq'). In Conditional expression they are connected with logical OR operator || and the whole returned phrase is taken in rounded brackets:

var statusId='${status.id}';
return (statusId==='5W4yldg4vR3XcAZy5L18' || statusId==='SqqdcjE6DrQkeLpHIIbm' || statusId==='30LQPgRAPWUMgQd1ZyWq');
info

It can happen that some statuses values are duplicated. Please check the appropriate id of the status value to be included into the expression. In order to do this, you have to navigate into Administration -> Statuses, open the status card and extract it's id from the url:

>

Skip on Rejected status

var statusId='${status.id}';
return statusId!=='5W4yldg4vR3XcAZy5L18';

status is a key for Select type attribute orientated for 'Lookup to object type'=Status. It will also work without exposing the attribute on the form as status is system attribute key.

'5W4yldg4vR3XcAZy5L18' is the text value for Id of Rejected status.

The step with the defined above Condition expression will be SKIPPED only in the case, the document status will be set as Rejected. Otherwise such step will be triggered (executed) while processing.

So typically such conditions will appear only for the steps which have to be executed in MAIN processing path of workflow, but should be omitted in every recurring loop of workflow after the document is Rejected.

Skip on 1 of a few statuses

This is the extension variant of the previous example. Additional 2 statuses are taken into the account: Pending ('SqqdcjE6DrQkeLpHIIbm') and Refused ('30LQPgRAPWUMgQd1ZyWq'). In Conditional expression they are connected with logical AND operator && and the whole returned phrase is taken in rounded brackets:

var statusId='${status.id}';
return (statusId!=='5W4yldg4vR3XcAZy5L18' && statusId!=='SqqdcjE6DrQkeLpHIIbm' && statusId!=='30LQPgRAPWUMgQd1ZyWq');
info

It can happen that some statuses values are duplicated. Please check the appropriate id of the status value to be included into the expression. In order to do this, you have to navigate into Administration -> Statuses, open the status card and extract it's id from the url:

>

Skip if employee (Select) is manager of her/his department

const employeeIdConst = '${employeeId.id}';
const managerIdConst = '${employeeId.departmentId.managerId}';
return !managerIdConst.includes(employeeIdConst);

employeeId is a key for Select type attribute which appoints to Object type=Person, Class=Employee

departmentId is a key of Department attribute (of Typehead type, for Department lookup), which is placed on Employee form

managerId is a key for Manager attribute, which is placed on department form.

info

In order to get to the department definition, you have to navigate into: Administration -> Company Name -> Departments -> Open department form

info

The second sublevel relation: '${employeeId.departmentId.managerId}' is allowed only in the Conditions Expressions in workflow. It will be not allowed in expressions of the attributes on the form. There is limitation up to 1 sublevel. In such case, on the form consultant is supposed to create separate attribute which appoint to the department, then use that attribute to extract managerId.

Skip if (employee or his direct manager) is a manager of the employee department

IN VERIFICATION
const employeeIdConst = '${employeeId.id}';
const lineManagerId = '${employeeId.managerId.id}';
const managerId = '${employeeId.departmentId.managerId}';
return !managerId.includes(employeeIdConst) && !managerId.includes(lineManagerId);

Skip if person (Select) is included in multi-select

//const multiPersons = '${workflowScheme.invoiceAccountants}';
const multiPersons = '${multiPer}';
const employeeIdConst = '${employeeId.id}';
return !multiPersons.includes(employeeIdConst);

employeeId is a key for Select type attribute which appoints to Object type=Person, Class=Employee

multiPer is a key for Multi-select type attribute which appoints to Object type=Person, Class=Employee

Duration expression