ResultEntity::runAutomation

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. ResultEntity
  4. runAutomation
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/webform/resultentity.php
  • Класс: Bitrix\Crm\WebForm\ResultEntity
  • Вызов: ResultEntity::runAutomation
protected function runAutomation()
{
	$bindings = array();
	foreach($this->resultEntityPack as $entity)
	{
		$isEntityAdded = !$entity['IS_DUPLICATE'];
		$entityTypeName = $entity['ENTITY_NAME'];
		$entityId = $entity['ITEM_ID'];

		$wasAutomationLaunchedInOperation =
			\CCrmOwnerType::isUseDynamicTypeBasedApproach(\CCrmOwnerType::ResolveID($entityTypeName))
			|| (
				$entityTypeName === \CCrmOwnerType::QuoteName
				&& Crm\Settings\QuoteSettings::getCurrent()->isFactoryEnabled()
			)
		;

		if (!$wasAutomationLaunchedInOperation)
		{
			$errors = array();
			\CCrmBizProcHelper::AutoStartWorkflows(
				\CCrmOwnerType::ResolveID($entityTypeName),
				$entityId,
				$isEntityAdded ? \CCrmBizProcEventType::Create : \CCrmBizProcEventType::Edit,
				$errors
			);

			if($isEntityAdded && empty($entity['IS_AUTOMATION_RUN']))
			{
				$starter = new Automation\Starter(\CCrmOwnerType::ResolveID($entityTypeName), $entityId);
				$starter->runOnAdd();
			}
		}

		$bindings[] = array(
			'OWNER_ID' => $entity['ITEM_ID'],
			'OWNER_TYPE_ID' => \CCrmOwnerType::ResolveID($entity['ENTITY_NAME'])
		);
	}

	if ($this->isCallback)
	{
		Automation\Trigger\CallBackTrigger::execute($bindings, array(
			'WEBFORM_ID' => $this->formId
		));
	}

	Automation\Trigger\WebFormTrigger::execute($bindings, array(
		'WEBFORM_ID' => $this->formId
	));
}

Добавить комментарий