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.
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 asyncfunctioncreateFilterForSearch() {
// 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();
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();
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 = awaitPromise. all(changes.map(change => change.data.item!.fetch()));
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
T: ItemData
P: ItemData
S: Processes
Hierarchy
Properties
Readonly cache
Cache for temporary data storage (isolated in the app).
Readonly fields
Description of app fields.
Readonly name
App name.
Readonly processes
Processes in the app.
Learn about other features in Processes.
Readonly serial
Counter in the app.
Readonly storage
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
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
The method checks permissions of a user, group, org chart item, or role.
Parameters
orgunit: TPermissionOrgunit
type: PermissionType
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
permissions: TPermissions
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>
Feedback sent successfully
Thank you for your input