Retrieving unit group (hierarchy) information
Unit, unit group, and hierarchy information can be retrieved with functions during import and in calculations (such as with K-fields). However, some functions only work when Org hierarchy filtering is either on of off. The following tables summarize the functions to use, and when you can use them.
| Retrieve... | Import spec | In calculations |
|---|---|---|
| Unit object (UNIT_OBJECT) | findUnit('unitId') |
unit('unitId') or, use the associated E-field, like |
| Unit Name | UNIT_OBJECT.name | name(UNIT_OBJECT) |
| Unit ID | UNIT_OBJECT.identifier | text(UNIT_OBJECT) |
| Unit data field | unitDataField(UNIT_OBJECT, 'u_fieldName') | getUnitDatafield(UNIT_OBJECT, 'fieldName') In the following example, the first parameter (e_unitid) is the unit field and the second parameter (myUnitDatafield) is the Keyname of the UnitDatafield that you want to return: getUnitDatafield(e_unitid, 'myUnitDatafield'); |
| Unit group object (GROUP_OBJECT) | findUnitGroup('group_id') | getUnitGroupFromOrgHierarchy('groupName') |
| Unit group Name | GROUP_OBJECT.name |
getUnitGroupDatafield(UNIT_OBJECT, 'groupId', levelsDown, 'name') or, use GROUP_OBJECT.name |
| Unit group ID | GROUP_OBJECT.identifier |
getUnitGroupDatafield(UNIT_OBJECT,'groupId', levelsDown,'identifier') or, use GROUP_OBJECT.identifier |
| Unit group data field | unitGroupDataField(GROUP_OBJECT, 'ug_fieldName') | getUnitGroupDatafield(UNIT_OBJECT, 'groupId', levelsDown, 'fieldName') Important: This function returns only one value. As such, the unit should cannot be related to more than one unit group in the same hierarchy level. |
| Retrieve... | Import spec | In calculations |
|---|---|---|
| Unit is in group | — | — |
| Group under a specific group | — | getUnitGroupFromOrgHierarchyOnField('parentGroupName', 'unitField') Example 1 — The first child UnitGroup under parent 'brand' for a specific unit field (e_unitid) on the record will be returned: getUnitGroupFromOrgHierarchyOnField('brand', 'e_unitid').name Example 2 — All unit groups under parent 'brand' for a specific unit field (e_unitid) stored on the record will be returned: getUnitGroupsFromOrgHierarchyOnField('brand', 'e_unitid') |
| All groups | — | getUnitGroupFromOrgHierarchy('parentGroupID') Example 1 — The first child UnitGroup under parent 'brand' stored on the record will be returned. Use .identifier to return the identifier. getUnitGroupFromOrgHierarchy('brand').name Example 2 — All unit groups under parent 'brand' stored on the record will be returned as an array of unit groups: getUnitGroupsFromOrgHierarchy('brand') |
| Retrieve... | Import spec | In calculations |
|---|---|---|
| Unit is in group | — | isUnitMemberOfUnitGroup(UNIT_OBJECT, 'group_id') The following example returns true if the given unit (e_unitid) is a member of the unit group with the given identifier (brand_A). if (isUnitMemberOfUnitGroup(e_unitid, 'brand_A')) { return 1; } else { return 2; } |
| Group under a specific group | — | getUnitGroupDatafield(UNIT_OBJECT, 'parentGroupName', levelsDown, 'fieldName') In the following example, the first child UnitGroup identifier under parent unit group 'brand' will be returned from the hierarchy. Use 'name' to return the name or 'identifier' to return the identifier. getUnitGroupDatafield(e_unitid, 'brand', 1, 'identifier') |
| All groups | directUnitGroups(UNIT_OBJECT) | — |
