- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/entitymanagefacility.php
- Класс: Bitrix\Crm\EntityManageFacility
- Вызов: EntityManageFacility::runAutomation
public function runAutomation()
{
// run on add
if ($this->canAdd() && $this->registeredId && $this->registeredTypeId)
{
// run business process
if (!$this->isBpRun)
{
$bpErrors = array();
\CCrmBizProcHelper::AutoStartWorkflows(
$this->registeredTypeId,
$this->registeredId,
\CCrmBizProcEventType::Create,
$bpErrors
);
// mark as BP run
$this->isBpRun = true;
}
// run automation
if (!$this->isEntityTypeConvertible($this->registeredTypeId))
{
$starter = new Automation\Starter($this->registeredTypeId, $this->registeredId);
$starter->runOnAdd();
}
}
elseif ($this->canUpdate() && $this->getPrimaryId() && $this->getPrimaryTypeId())
{
// run business process
$bpErrors = array();
\CCrmBizProcHelper::AutoStartWorkflows(
$this->getPrimaryTypeId(),
$this->getPrimaryId(),
\CCrmBizProcEventType::Edit,
$bpErrors
);
// TODO: call Automation\Starter::runOnUpdate on entity update.
}
return $this;
}