Type parameters

Hierarchy

Properties

Readonly code

code: string

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

Readonly data

data: Based<Partial<UserGroupData>>

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

addItem

  • The method adds users, org chart items, and groups to a user group.

    Parameters

    • Rest ...children: (UserItemRef | UserGroupItemRef | OrganisationStructureItemRef)[]

      List of users, org chart items, and groups.

      const  targetGroup = await System.userGroups.search().where(f => f.__name.eq( 'Meeting participants')).first();
      const group = await System.userGroups. search().where(f => f.__name.eq('Superiors')).first(); 
      const os = await  System.organisationStructure.fetchTree(); 
      const position = os.find( 'Advertising Director'); 
      await targetGroup.addItem(group, position, Context. data.user); 
      

    Returns Promise<void>

delete

  • delete(): Promise<void>
  • The method is used to delete user groups.

    const group = await System.userGroups.search().where(f =>  f.__name.eq('Customer service employees (outdated)')).first();
    const  parentGroups = await group.parentGroups(); 
    if (parentGroups &&  parentGroups.length === 0) { 
        await group.delete(); 
    } 
    

    Returns Promise<void>

fetch

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

parentGroups

  • The method obtains a list of groups that the current group is included in.

    const parentGroups = await group.parentGroups();
    

    Returns Promise<UserGroupItem[]>

positions

  • The method receives a list of positions included in a group.

    const groupName = 'Workspace administrators';
    const group =  await System.userGroups.search().where(g => g.__name.eq(groupName)).first();  
    const positions = await group.positions(); 
    

    Returns Promise<OrganisationStructureItem[]>

save

  • save(): Promise<void>
  • The method is used to save user groups.

    const serviceEmployeesGroup = await  System.userGroups.search().where(f => f.__name.eq('Service employees')).first();
    await serviceEmployeesGroup.addItem(Context.data.new_employee); 
    await  serviceEmployeesGroup.save(); 
    

    Returns Promise<void>

subGroups

  • The method returns all nested groups.

    const group = await System.userGroups.search().where(f =>  f.__name.eq('Meeting participants')).first();
    const subGroups = await  group.subGroups(); 
    

    Returns Promise<UserGroupItem[]>

users

  • users(from?: undefined | number, size?: undefined | number): Promise<UserItem[]>
  • The method returns users included in the group.

    Parameters

    • Optional from: undefined | number

      Which position (in the array) to start returning users from. The default value is 0.

    • Optional size: undefined | number

      How many users to return. The default value is 10.

      const  group = await System.userGroups.search().where(f => f.__name.eq('Superiors')) .first();
      const groupMembers = await group.users(0, 20); 
      

    Returns Promise<UserItem[]>