21 public function startAction($scriptId, array $documentIds, array $parameters = [])
23 $userId = $this->getCurrentUser()->getId();
24 $documentIds = array_unique($documentIds);
29 'status' => static::START_STATUS_NOT_PERMITTED,
31 'BIZPROC_CONTROLLER_SCRIPT_ERROR_DOCUMENT_ID_LIMIT',
34 '#SELECTED#' => count($documentIds),
44 'status' => static::START_STATUS_NOT_EXISTS,
48 if (!$script->getActive())
51 'status' => static::START_STATUS_NOT_PERMITTED,
52 'error' =>
Loc::getMessage(
'BIZPROC_CONTROLLER_SCRIPT_CANT_START_INACTIVE')
59 'status' => static::START_STATUS_NOT_PERMITTED,
61 'BIZPROC_CONTROLLER_SCRIPT_ERROR_QUEUES_LIMIT',
70 $script->fill(
'WORKFLOW_TEMPLATE');
71 $tpl = $script->getWorkflowTemplate();
75 'status' => static::START_STATUS_NOT_EXISTS,
80 $templateParameters = $tpl->getParameters();
81 if ($templateParameters)
83 $parameters = $this->grabParameters($templateParameters, $parameters);
85 if (empty($parameters))
88 'status' => static::START_STATUS_FILL_PARAMETERS,
89 'parameters' => self::convertTemplateParameters($templateParameters, $tpl->getDocumentComplexType()),
90 'documentType' => $tpl->getDocumentComplexType(),
91 'scriptName' => $script->getName(),
97 if (!$result->isSuccess())
99 $error = $result->getErrors()[0];
103 'status' => static::START_STATUS_NOT_PERMITTED,
104 'error' => $error->getMessage(),
110 'status' => static::START_STATUS_INVALID_PARAMETERS,
111 'error' => $error->getMessage(),
116 'error' => $error->getMessage(),
121 'status' => static::START_STATUS_QUEUED,
122 'queueId' => $result->getData()[
'queueId'],