• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/automation/engine/template.php
  • Класс: Bitrix\Crm\Automation\Engine\Template
  • Вызов: Template::addBizprocTemplate
protected function addBizprocTemplate($userId)
{
	$userId = (int)$userId;
	$documentType = array(
		'crm',
		\CCrmBizProcHelper::ResolveDocumentName($this->template['ENTITY_TYPE_ID']),
		\CCrmOwnerType::ResolveName($this->template['ENTITY_TYPE_ID'])
	);

	$raw = $this->getBizprocTemplate();
	$raw['DOCUMENT_TYPE'] = $documentType;
	$raw['NAME'] = Loc::getMessage('CRM_AUTOMATION_TEMPLATE_NAME', array(
		'#STATUS#' => $this->template['ENTITY_STATUS']
	));
	$raw['USER_ID'] = $userId;
	$raw['MODIFIER_USER'] = new \CBPWorkflowTemplateUser($userId);

	$result = new Result();
	try
	{
		$raw['ID'] = \CBPWorkflowTemplateLoader::Add($raw, $userId === 1);
		$result->setData(array('ID' => $raw['ID']));

		$this->bizprocTemplate = $raw;
	}
	catch (\Exception $e)
	{
		$result->addError(new Error($e->getMessage()));
	}

	return $result;
}