CCrmRequisiteRestProxy::innerAdd

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmRequisiteRestProxy
  4. innerAdd
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/restservice.php
  • Класс: \CCrmRequisiteRestProxy
  • Вызов: CCrmRequisiteRestProxy::innerAdd
protected function innerAdd(&$fields, &$errors, array $params = null)
{
	$entityTypeID = intval($this->resolveParam($fields, 'ENTITY_TYPE_ID'));
	$entityID = intval($this->resolveParam($fields, 'ENTITY_ID'));
	$presetID = intval($this->resolveParam($fields, 'PRESET_ID'));

	if(!$this->isValidID($entityTypeID) || !CCrmOwnerType::IsDefined($entityTypeID))
	{
		$errors[] = 'ENTITY_TYPE_ID is not defined or invalid.';
		return false;
	}
	if(!$this->checkEntityID($entityID))
	{
		$errors[] = 'ENTITY_ID is not defined or invalid.';
		return false;
	}
	if(!$this->checkEntityID($presetID))
	{
		$errors[] = 'PRESET_ID is not defined or invalid.';
		return false;
	}

	if(!EntityRequisite::checkCreatePermissionOwnerEntity($entityTypeID))
	{
		$errors[] = 'Access denied.';
		return false;
	}

	if (!$this->entityExists($entityTypeID, $entityID))
	{
		$errors[] = 'Entity not found.';
		return false;
	}

	$entity = self::getEntity();

	$result = $entity->add($fields);

	if(!$result->isSuccess())
	{
		$errors = $result->getErrors();
		return false;
	}
	else
	{
		CCrmEntityHelper::NormalizeUserFields($fields, EntityRequisite::$sUFEntityID, $GLOBALS['USER_FIELD_MANAGER'], array('IS_NEW' => true));
		$GLOBALS['USER_FIELD_MANAGER']->Update(EntityRequisite::$sUFEntityID, $result->getId(), $fields);

		if(self::isBizProcEnabled())
		{
			CCrmBizProcHelper::AutoStartWorkflows(
					CCrmOwnerType::Requisite,
					$result->getId(),
					CCrmBizProcEventType::Create,
					$errors
			);
		}
	}

	return $result->getId();
}

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