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'; 
} 

Type parameters

Hierarchy

Properties

Readonly code

code: string

App code of the URL’s target (the app’s code).

Readonly data

data: Based<Partial<OrganisationStructureData>>

Values of object’s fields.

Readonly fields

fields: Readonly<object>

Description of the object’s fields.

Readonly id

id: string

ID of the URL’s target.

Readonly namespace

namespace: string

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

    Returns void

fetch

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 
      } 
      

    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

  • isDepartment(): boolean
  • The method returns true if the item is a department and false 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

  • isGroup(): boolean
  • The method returns true if the item is a group and false 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

  • isPosition(): boolean
  • The method returns true if the item is a position and false 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

  • moveAfter(): void
  • 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

  • moveBefore(): void
  • 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

    Returns void

normalize

  • normalize(): void
  • 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

    Returns void