Documentation

StartWorkflow

string
public static function CBPDocument::StartWorkflow(
 integer workflowTemplateId,
 array documentId,
 array arParameters,
 array &arErrors
);

This method launches workflow by its template code. This method is recommended to launch workflows.

Note: This method receives an array of configuration parameters and generates scripts, required to show file dialog. Static method.

Method parameters

ParameterDescription
workflowTemplateIdWorkflow template ID code.
documentIdDocument ID code as an array(module, document_class, document_code_in_module)
arParametersArray of parameters to launch a workflow.

Note: If the process is launched from another process via API, and a multiple parameter value is passed, then it must be passed as an array.

arErrorsArray of error, which occurred during workflow launch as follows
array(
array(
"code" => error_code,
"message" => message,
"file" => path_to_file
),
...
).

Returned value

Launched workflow ID is returned. Array of error is filled in case of an error.

See Also

Examples of use

<?

// Launch workflow from a $workflowTemplateId template with input parameters $arWorkflowParameters
// for the document array("bizproc", "CBPVirtualDocument", $documentId)

$arErrorsTmp = array();

$wfId = CBPDocument::StartWorkflow(
$workflowTemplateId,
array("bizproc", "CBPVirtualDocument", $documentId),
array_merge($arWorkflowParameters, array("TargetUser" => "user_".intval($GLOBALS["USER"]->GetID()))),
$arErrorsTmp
);

if (count($arErrorsTmp) > 0)
{
foreach ($arErrorsTmp as $e)
$errorMessage .= "[".$e["code"]."] ".$e["message"]."
";
}
?>


© «Bitrix24», 2001-2024