Documentation

ParentFieldManager

Attention! This information is provided for informational purposes. This class may be subjected to refactoring soon, so please do not use it in your code.

\Bitrix\Crm\Service\ParentFieldManager - service object, received via container.

Many locations require to show bindings between items. This service allows to receive package data about parent items for further display in CRM interfaces.

Method Description Available from version
ParentFieldManager::getParentFieldName(
   $entityTypeId
): string
Returns parent field code by CRM ID, such as $entityTypeId. For example, if $entityTypeId = 128, result is PARENT_ID_128
ParentFieldManager::getEntityTypeIdFromFieldName(
   string $fieldName
): int
Returns CRM type ID by $fieldName field code. For example, when $fieldName = PARENT_ID_128, result is 128
ParentFieldManager::isParentFieldName(
   string $fieldName
): bool
Returns true, when $fieldName is parent field code.
ParentFieldManager::getParentFields(
   int[] $itemIds,
   string[] $entityFields,
   int $entityTypeId
): array[]
Method returns multi-level array with description of parents for passed items:
  • int[] $itemIds - array with item IDs, to retrieve parents data
  • string[] $entityFields - array with names for all fields to be displayed in the UI (grid, kanban). Using field names, ParentFieldManager defines, which fields contain information about parent items and their entity types. When fields среди полей нет тех, которые указывают на родителей, метод вернет пустой массив
  • int $entityTypeId - entityTypeId for descendant entity, for which to receive parents data. Shows entity type for items from $itemIds.

Returned array has the following structure:

$parents = [
	// Top level keys (16 and 34) - are item IDs from $itemIds
	// When passed item doesn't have parents, this item with such key is excluded from the array
	// (isset($parents[$itemId]) === false)
	16 => [
		// Second level keys (2 and 7) - its entityTypeId for parent entities
		2 => [
			'id' => '84',
			'code' => 'PARENT_ID_2',
			'entityDescription' => 'Deal',
			'title' => 'Specific item name, escaped',
			'url' => '/crm/deal/details/84/',
			'value' => 'Specific item name, escaped',
		],
		7 => [
			'id' => '657',
			'code' => 'PARENT_ID_7', 
			'entityDescription' => 'Quote', 
			'title' => 'Specific item name, escaped', 
			'url' => '/crm/quote/details/657/', 
			'value' => 'Specific item name, escaped',
		],
	],
	34 => [
		7 => [
			'id' => '485',
			'code' => 'PARENT_ID_7', 
			'entityDescription' => 'Quote', 
			'title' => 'Specific item name, escaped', 
			'url' => '/crm/quote/details/485/', 
			'value' => ' Specific item name, escaped ',
		],
	],
];

© «Bitrix24», 2001-2024
Up