Application

App object

Can be accessed in business processes and widgets associated with apps.
The Application object provides methods and data to work with the current app.

Type parameters

Hierarchy

  • Application

Properties

Readonly cache

cache: ICache

Cache for temporary data storage (isolated in the app).

Readonly fields

fields: Readonly<object>

Description of app fields.

Readonly name

name: string

App name.

Readonly processes

processes: S

Processes in the app.

Learn about other features in Processes.

Readonly serial

serial: Serial

Counter in the app.

Readonly storage

storage: IStorage

Long-term storage used to store any string data on the server (isolated in an app).

Methods

batch

  • Use batch action.

    Used to save, update, or delete multiple app items. To execute bulk actions from client scripts, the current user must be granted permissions to import data in the app. To execute them from server scripts, no additional permissions are required.

    Returns ApplicationBatcher<T, P>

create

  • The method allows creating a new app item.

    After you initiate app item creation and fill out the item's fields, you need to save it using the BaseApplicationItem.save method.

    const item = Application.create();
    item.data.__name = Context. data.request_subject; 
    await item.save(); 
    

    Returns ApplicationItem<T, P>

createFilter

  • Creats a filter by app items.

    Used in the search widget to create a filter by which the app items will be searched. Defines only the search condition without pagination, sorting, or the search itself. Unlike Application.search, the result is a ready-to- use filter that can be passed to ApplicationSearch.where.

    // Function to create a filter by which app items will be  searched 
    async function createFilterForSearch() { 
        // Build the filter  condition for app items: 
        // the item is not deleted, and its name  contains the value from the `name` variable 
        return  Application.createFilter().where((f, g) => g.and ( 
            f.__deletedAt.eq(null), 
            f.__name.like (ViewContext.data.name ?? ''), 
        )); 
    } 
    
    // Applying  the filter to the app item search 
    const filter =  Application.createFilter().where((f, g) => g.and( 
        f.__deletedAt.eq(null) , 
        f.__name.like(ViewContext.data.name ?? ''), 
    )); 
    const items = await  Application.search() 
        .where(filter) 
        .all(); 
    

    Returns ApplicationFilter<T>

createFolder

  • createFolder(name: string): Promise<TFolder>
  • The method creates a new folder in the app (on the first nesting level).

    In this example, we use the method to create a new folder in an app.

    const folder = await Application.createFolder('name');
    

    Parameters

    • name: string

    Returns Promise<TFolder>

getFolders

  • The method returns an array of app folders (on the first nesting level).

    In this example, we use the method to get all folders in the app.

    const folders = await Application.getFolders();
    

    Returns Promise<TFolder[]>

    Folders set up in an app.

getPermissions

  • The method retrieves access permissions set for the app item.

    Learn more about how the method works in [[BaseApplicationItem. getPermissions]].

    Returns Promise<TPermissionsSettings>

getSettings

  • Returns settings set for the app.

    const settings = await Application.getSettings();
    // Whether  registration is enabled 
    const on_registry =  settings.registrationSettings.enabled 
    // List of IDs of folders available  for this app 
    const nomIDs = settings.registrationSettings.nomenclatureIds  
    // Returns a list of folders available for the app 
    const nomenclatures =  settings.registrationSettings.getNomenclatures(); 
    

    Returns Promise<TSettings>

hasPermission

  • hasPermission(orgunit: TPermissionOrgunit, type: PermissionType): Promise<boolean>
  • The method checks permissions of a user, group, org chart item, or role.

    Parameters

    Returns Promise<boolean>

search

  • The method can be used to search for an app item.

    Learn more about searching for app items in the Manage apps article.

    Returns ApplicationSearch<T, P>

setPermissions

  • The method sets new access permissions for an app item.

    Learn more about how the method works in [[BaseApplicationItem. setPermissions]].

    Parameters

    Returns Promise<void>

statusHistory

  • The method is used to search in an app item’s status change history.

    The method returns the StatusHistorySearch object that supports filtration and sorting of search results.

    // Let’s history  of assigning the `done` status 
    // over the last day 
    const today = new  Datetime(); 
    const yesterday = today.addDate(0, 0, -1); 
    const changes =  Application.statusHistory() 
        .where((f, g) => g.and( 
            f. __createdAt.gte(yesterday), 
            f.target.eq(Application.fields.__status. variants.done.id), 
        )) 
        .all(); 
    // Let’s get full data for all  items 
    // whose status changes to `done` 
    const items = await Promise. all(changes.map(change => change.data.item!.fetch())); 
    

    Returns StatusHistorySearch<T, P>