Flow Control in business processes - this group contains managing structures.
Wait for Event
This action’s execution depends on the users. A specific control element will be created for them. The command interrupts a business process pending the user’s action.
Action Parameters
The event can be sent by – permits limiting a circle of users for whom this command is available.
Let's consider a short example of using this action.
In this example, having performed the action block, the business process will stop and wait for the user to decide which branch the events will follow.
You should open the created element (all business processes and their elements are in Automation > Workflows in Feed section) and select the command in the Business processes tab.
Condition
The structure permits you to direct a business process according to different scenarios depending on preset conditions.
Condition Type – Element Field
This action branch of the condition will be executed if the parameters related to the element fields coincide.
Condition Type – Variable Value
This action branch of the condition will be executed if the parameters related to business process variables coincide. The values of both variables and template parameters can be used in this type.
Condition Type – Mixed
You can specify a condition for different sources with the help of this action branch. Thus, there is no need to create separate action branches to check each condition.
For example, you can select variables, element fields, or constants and specify the conditions for them.
Condition Type – True
This action branch will be executed immediately. This condition is always met. This condition type comes in handy if none of the other conditions is met.
The conditions are checked from left to right. It is recommended to make such a condition branch the right-most one.
Condition Type – PHP Code
The code is indicated as a condition.
If the indicated PHP code returns the value true
, the branch of actions below such a condition will be executed; if false
is returned, the next condition will be checked.
Note: Only a user with administrator’s rights can set a PHP code.
Attention! Only a PHP code can be used for this type of condition. The parameters of the type {=Variable:Variable2_printable}
are not supported.
The code executed in the condition must also result in a logical expression (true
or false
).
Condition Type – Modified Document Fields
If the business process is autorun when changed, there is an option to check the field changes of the element. The action branch will be executed if you enter some modifications in a field.
To use this condition type, you need to apply the settings on the module side. When starting a business process, 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 business process editor:
public static function isFeatureEnabled($documentType, $feature) { return in_array($feature, array(\CBPDocumentService::FEATURE_MARK_MODIFIED_FIELDS)); }
Attention! If no condition is met, the business process will continue executing the actions located under the Condition structure. In other words, it will 'skip' the structure.
Listening for Parallel Event
This structure permits you to direct a business process according to different scenarios depending on which event occurs earlier.
To choose the action branch, this structure must use the actions Wait for Event or Pause Execution first.
In other words, the action that occurs earlier in any branch will result in the execution of the chain below such an action.
This action Pause Execution permits you to resume a business process at a certain time in case no command is executed. Otherwise, the business process will just stop and wait for the execution of any command inside the structure.
Parallel Execution
This action runs the simultaneous execution of multiple action branches. If one of the action branches is not executed in the Parallel Execution structure, the business process will stop until its execution.
Set Status
This action permits you to change the status of a business process.
Also, this action 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 action enumerates values of multiple-value sources. You can create a cycle of actions 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 actions for all the selected values entered in the field or variable.
For example, you have a variable with the Link to Employee type. It contains a list of users in your account. You need to create a task for each of these users sequentially. To do it, select the variable with the employees list in the Iterator parameters and add the Create task action 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 action 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 so far as a given condition is met.
In other words, the cycle works so far as the condition is valid (true
), otherwise (false
) the loop is terminated.
Condition Type – Element Field
The loop will continue operating so long as the parameters related to the element fields coincide.
Condition Type – Variable Value
The loop will continue operating so far as parameters related to variables of the business process coincide.
Condition Type – Mixed
You can specify a condition for different sources with the help of this action branch. Thus, there is no need to create separate action branches to check each condition.
For example, you can select variables, element fields, or constants and specify the conditions for them.
Condition Type – PHP Code
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 be terminated.
Condition Type – True
In this case, the loop will always be executed.