Wait for Event
The activity pauses a workflow execution and waits for a user to run an action.
The only activity parameter is The event can be sent by. Choose a circle of users who can execute this command.
Consider a short example of using this activity. Having performed the activity block, the workflow will stop and wait for the user to decide which branch the events will follow.
To execute a command,
- Go to Automation > Workflows.
- Find and open the created element.
- Open the Business Processes tab.
- Select a command next to Run Action.
- Click the Execute Commands button.
Condition
The structure permits you to direct a workflow to different branches depending on preset conditions.
There are different condition types:
Element Field. The activity branch of the condition will be executed if the parameters related to the element fields coincide.
Variable Value. The activity branch of the condition will be executed if the parameters related to workflow variables coincide. You can use the values of both variables and template parameters in this condition type.
Mixed. Set a condition for different sources using this activity branch. Thus, there is no need to create separate activity branches to check each condition. You can select variables, element fields, or constants and specify conditions for them.
True. The activity branch will be executed immediately, and the condition is always met. This condition type comes in handy if none of the other conditions are met.
PHP Code. The code is indicated as a condition.
The code in the condition must result in a logical expression (true
or false
). If the indicated PHP code returns the value true
, the branch of activities below such a condition will be executed. If false
is returned, the next condition will be checked.
- Only a user with administrative rights can set a PHP code.
- Only a PHP code can be used for this type of condition. The parameters of the type
{=Variable:Variable2_printable}
are not supported.
Modified Document Fields. If the workflow is autorun when changed, there is an option to check the field changes of the element. The activity branch will be executed if you enter some modifications in a field.
You can use this condition type only after additional configuration of the module. Find the instructions below.
How to set up the Modified Document Fields condition type (for developers)
To use this condition type, you need to apply the settings on the module side. When starting a workflow, it is required to pass an array of the modified fields using the parameter CBPDocument::PARAM_MODIFIED_DOCUMENT_FIELDS
:
CBPDocument::StartWorkflow( $arDocumentState["TEMPLATE_ID"], BizProcDocument::getDocumentComplexId($arParams["IBLOCK_TYPE_ID"], $arResult["ELEMENT_ID"]), array_merge($arBizProcParametersValues[$arDocumentState["TEMPLATE_ID"]], array( CBPDocument::PARAM_TAGRET_USER => "user_".intval($GLOBALS["USER"]->GetID()), CBPDocument::PARAM_MODIFIED_DOCUMENT_FIELDS => $modifiedFields )), $arErrorsTmp );
Also, you need to implement support for this condition type in a document to see it in the workflow editor:
public static function isFeatureEnabled($documentType, $feature) { return in_array($feature, array(\CBPDocumentService::FEATURE_MARK_MODIFIED_FIELDS)); }
Listening for Parallel Event
This structure allows you to direct a workflow to different branches depending on which event occurs earlier. In other words, the activity that occurs earlier in any branch will result in the execution of the chain below such an activity.
To choose an activity branch in this structure, use the Wait for Event or Pause Execution activity.
The Pause Execution activity permits you to resume a workflow at a certain time in case no command is executed. Otherwise, the workflow will just stop and wait for the execution of any command inside the structure.
Parallel Execution
This activity runs the simultaneous execution of multiple activity branches. If one of the activity branches is not executed in the Parallel Execution structure, the workflow will stop until its execution.
Set Status
The activity permits you to change the workflow status.
Also, this activity has the Abort current status option. It immediately moves an element to the specified status without waiting for the completion of the previous one.
Iterator
This activity enumerates the values of multiple-value sources. You can create a cycle of activities that will be executed for each value, one by one.
Select a multiple-value variable, element field, or constant in activity parameters.
After that, you can arrange the execution of the set of similar activities for all the selected values entered in the field or variable.
For example, you have a variable with the Link to Employee type, which contains a list of account users. You need to create a task for each of these users sequentially. To do it, select the variable in the iterator parameters and add the Create task activity to the construction.
To use each time the next value of the multiple-value variable in the cycle, insert the Value item from the Additional Results of Iterator.
While Loop
If there is an error and the process repeats endlessly in the loop, the activity will be executed 1,000 times, and 1,000 emails will be sent from your account. There will be no way to stop the sending in this case.
Make sure that the While Loop structure works properly, then use it to send emails.
The structure executes its subactions as long as a given condition is met. In other words, the cycle works as long as the condition is valid (true
), otherwise (false
) the loop ends.
There are different condition types:
Element Field. The loop will continue operating as long as the parameters related to the element fields coincide.
Variable Value. The loop will continue operating as long as parameters related to the workflow variables coincide. You can use the values of both variables and template parameters in this type.
Mixed. Set a condition for different sources using this activity branch. Thus, there is no need to create separate activity branches to check each condition. You can select variables, element fields, or constants and specify conditions for them.
PHP Code. The code is indicated as a condition.
If the indicated PHP code returns the value true
, the loop will continue operating. If false
is returned, the loop will end.
True. The loop will always be executed.