Order::updateDocumentUserFields

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Order
  4. updateDocumentUserFields
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/bizproc/document/order.php
  • Класс: Bitrix\Crm\Integration\BizProc\Document\Order
  • Вызов: Order::updateDocumentUserFields
static function updateDocumentUserFields($orderId, $fields)
{
	$values = [];

	foreach (static::getUserFieldsMap() as $fieldId => $field)
	{
		if (!isset($fields[$fieldId]))
		{
			continue;
		}

		if ($field['Type'] === 'user')
		{
			$values[$fieldId] = \CBPHelper::ExtractUsers(
				$fields[$fieldId],
				['crm', __CLASS__, $orderId],
				!$field['Multiple']
			);
		}
		elseif ($field['Type'] === 'select')
		{
			static::InternalizeEnumerationField(
				\CCrmOwnerType::ResolveUserFieldEntityID(\CCrmOwnerType::Order),
				$fields,
				$fieldId
			);
			$values[$fieldId] = $fields[$fieldId];
		}
		elseif ($field['Type'] === 'bool')
		{
			$values[$fieldId] = \CBPHelper::getBool($fields[$fieldId]) ? 1 : 0;
		}
		else
		{
			$values[$fieldId] = $fields[$fieldId];
		}
	}

	if ($values)
	{
		Application::getUserTypeManager()->update(
			\CCrmOwnerType::ResolveUserFieldEntityID(\CCrmOwnerType::Order),
			$orderId,
			$values
		);
	}
}

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