Type parameters
Hierarchy
- BaseItem<OrganisationStructureData>
- ItemRef<OrganisationStructureItem>
-
OrganisationStructureItemRef
- OrganisationStructureItem
Properties
Readonly code
App code of the URL’s target (the app’s code).
Readonly data
Values of object’s fields.
Readonly fields
Description of the object’s fields.
Readonly id
ID of the URL’s target.
Readonly namespace
Namespace of the URL target (the code of the workspace that the app belongs to).
Methods
addChild
-
The method allows you to add a child org chart item for the current item.
Parameters
-
item: OrganisationStructureItem
Org chart item that needs to be added.
someItem. addChild(item);
Returns void
-
fetch
-
Request complete data of a reference object.
Returns Promise<OrganisationStructureItem>
find
-
The method allows you to search among items in a tree with the current item at the root.
This returns the first item that satisfies the predicate or
undefined
if no such items are found.Parameters
-
predicate: function
Predicate used to search in a nested tree.
const item = tree. getRoot().find(i => i.data.name === 'Managers' && i.data.type === OrganisationStructureItemType.Group); if (item === undefined) { // Item not found }
-
Parameters
Returns boolean
-
Returns OrganisationStructureItem | undefined
-
getChildren
-
The method allows you to get child items of the current item.
const children = someItem.getChildren();
If the item has no child items, the method returns an empty array.
Returns OrganisationStructureItem[]
getParent
-
The method allows you to get the parent org chart item for the current item.
const parent = someItem.getParent();
If the item has no parent, the method will return “undefined”.
Returns OrganisationStructureItem | undefined
isDepartment
-
The method returns
true
if the item is a department andfalse
if it isn’ t.const item = tree.getRoot().find(i => i.data.name === 'Managers'); if (item && item.isDepartment()) { // `item` is a department }
Returns boolean
isGroup
-
The method returns
true
if the item is a group andfalse
if it isn’t.const item = tree.getRoot().find(i => i.data.name === 'Managers'); if (item && item.isGroup()) { // `item` is a group }
Returns boolean
isPosition
-
The method returns
true
if the item is a position andfalse
if it isn’t.const item = tree.getRoot().find(i => i.data.name === 'Managers'); if (item && item.isPosition()) { // `item` is a position }
Returns boolean
moveAfter
-
The allows you to move an item one position to the right in the org chart.
Items are moved on the same level of the org chart, that is, among child items of the same parent item. This method only affects the way the org chart looks on the editing page.
someItem.moveAfter();
Returns void
moveBefore
-
The allows you to move an item one position to the left in the org chart.
Items are moved on the same level of the org chart, that is, among child items of the same parent item. This method only affects the way the org chart is displayed on the editing page.
someItem. moveBefore();
Returns void
moveToParent
-
The method allows you to make the current item a child item to the specified item.
Parameters
-
parent: OrganisationStructureItem
New parent of the item.
someItem.moveToParent(newParent);
Returns void
-
normalize
-
Delete duplicate data in arrays.
The method deletes duplicates in fields that store arrays of links to system objects (users, files, app items, or documents). For example, you can call this method after bulk editing data within an object.
const app1 = await Context.data.app1.fetch(); const app2 = await Context.data.app2 .fetch(); app1.data.executors.push(app2.data.executors); app1.normalize(); // Now we need to go over the elements in the new array app1.data.executors .forEach( ... );
Returns void
removeChild
-
The method is used to delete one or more child items of the current item.
Parameters
-
item: OrganisationStructureItem | OrganisationStructureItem[]
Org chart items to be removed.
someItem.removeChild(item);
Returns void
-
Organizational chart item
This item represents an org chart item: a job position, a department, or a group. The type has no constructor. You can create a new item using the OrganisationStructure.createItem method:
const item = System.organisationStructure.createItem('Chief Development Officer', OrganisationStructureItemType.Position);
To add a newly created item to an existing org chart (to a specified parent), use the
OrganisationStructureItem.addChild method. When changes to the org chart are made, save it using the OrganisationStructure.save method.
const tree = await System.organisationStructure.fetchTree(); tree.getRoot().addChild(item); const errs = await System. organisationStructure.save(tree); if (errs.length === 0) { Context.data.debug = 'Saved successfully'; }