RestService :: startWorkflow: Bitrix method

      
<?php 
//  Bitrix\Bizproc\RestService :: startWorkflow()
//  /dist/bitrix/modules/bizproc/lib/restservice.php:645

    
public static function startWorkflow($params$n$server)
    {
        
$params array_change_key_case($paramsCASE_UPPER);

        if (empty(
$params['TEMPLATE_ID']))
        {
            throw new 
RestException('Empty TEMPLATE_ID'self::ERROR_WRONG_WORKFLOW_ID);
        }

        
$documentId self::validateDocumentId($params['DOCUMENT_ID']);
        
$templateId = (int)$params['TEMPLATE_ID'];
        
self::checkStartWorkflowPermissions($documentId$templateId);

        
$workflowParameters = isset($params['PARAMETERS']) && is_array($params['PARAMETERS']) ? $params['PARAMETERS'] : [];

        
$workflowParameters[\CBPDocument::PARAM_TAGRET_USER] = self::getCurrentUserId();

        
$errors = [];
        
$workflowId = \CBPDocument::startWorkflow($templateId$documentId$workflowParameters$errors);

        if (!
$workflowId)
        {
            throw new 
RestException($errors[0]['message']);
        }

        return 
$workflowId;
    }