DealNew::save

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. DealNew
  4. save
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/recurring/entity/item/dealnew.php
  • Класс: Bitrix\Crm\Recurring\Entity\Item\DealNew
  • Вызов: DealNew::save
public function save()
{
	$result = new Main\Result();
	if ((int)($this->templateId) <= 0 && empty($this->templateFields))
	{
		$result->addError(new Main\Error('Error saving. Template deal ID is empty.'));
		return $result;
	}

	if (!empty($this->templateFields))
	{
		$r = $this->saveDealTemplate();
		if (!$r->isSuccess())
		{
			return $r;
		}

		$this->templateId = $r->getId();
		$this->setFieldNoDemand('DEAL_ID', $this->templateId);
	}

	$addResult = $this->add();
	if ($addResult->isSuccess())
	{
		$this->id = $addResult->getId();
		$result->setData([
			'ID' => $this->id,
			'DEAL_ID' => $this->templateId,
		]);

		$this->onAfterSave();
	}
	else
	{
		$result->addErrors($addResult->getErrors());
	}

	return $result;
}

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