Document::checkFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Document
  4. checkFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/activity/provider/document.php
  • Класс: Bitrix\Crm\Activity\Provider\Document
  • Вызов: Document::checkFields
static function checkFields($action, &$fields, $id, $params = null): Result
{
	$result = new Result();

	$fields['PROVIDER_TYPE_ID'] = self::PROVIDER_TYPE_ID_DOCUMENT;

	if ($action === self::ACTION_ADD)
	{
		$documentId = (int)($fields['ASSOCIATED_ENTITY_ID'] ?? 0);
		if ($documentId <= 0)
		{
			return $result->addError(new Error('ASSOCIATED_ENTITY_ID is required for ' . self::class));
		}

		$anotherActivityForSameDocument = self::getActivityByAssociatedEntity($documentId);
		if (!empty($anotherActivityForSameDocument))
		{
			return $result->addError(new Error('Every document can have only one ' . self::class . ' activity bound to it'));
		}
	}

	return $result;
}

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