Hierarchy
- TFolder
Properties
Optional __deletedAt
Date and time of deletion.
id
ID of the folder.
level
Nesting level of the folder located in an app.
name
Name of the folder.
Methods
createFolder
-
The method creates a child folder.
In this example, we use the method to get a folder that an app item is located in and create a new folder in it.
const folder = await Context.data.item?.getFolder(); const childFolder = await folder. createFolder('name');
Parameters
-
name: string
Name of the new folder.
Returns Promise<TFolder>
-
getChildren
-
The method returns an array of child folders.
The example below shows how to use the method to get all folders of the second nesting level. They are considered child folders of folders inside the app.
const folders = await Application.getFolders(); const allChildren: TFolder[] = []; folders.forEach(folder => { const children = await folder.getChildren(); allChildren.push(...children); });
Returns Promise<TFolder[]>
Child folders.
getParent
-
The method returns the parent folder.
The example shows how to get the parent folder of a folder in an app.
const folder = await Context.data.item?.getFolder(); const parentFolder = await folder.getParent();
Returns Promise<TFolder | undefined>
Parent folder or
undefined
if the folder is top-level.
getPermissions
-
The method returns access permissions set for the folder.
Use this method if you need to add new access permissions to those that already exist. In the example, we used the method to get the current permissions to the folder and add new update permissions for the process initiator.
const folder = await Context.data.item?. getFolder(); const user = Context.data.__createdBy; if (folder) { const currPermissions = await folder.getPermissions() currPermissions. values.push(new PermissionValue(user, [PermissionType.UPDATE])) await folder.setPermissions(currPermissions); }
Returns Promise<TPermissions>
Access permissions set for the folder.
setName
-
The method allows you change the folder name.
Example:
const folders = await Application.getFolders(); if (folders.length !== 0) { const folder = folders[0]; await folder. setName('NEW_NAME'); }
Parameters
-
name: string
Returns Promise<void>
-
setPermissions
-
The method sets new access permissions for the folder.
The method completely replaces the existing access permissions with new ones. In the example, we used the method to set new permissions to a folder for the process initiator.
const folder = await Context.data. item?.getFolder(); const user = Context.data.executor; if (folder) { const permissions = new Permissions([new PermissionValue(user, [ PermissionType.DELETE, PermissionType.UPDATE])]); await folder. setPermissions(permissions); }
Parameters
-
permissions: TPermissions
Access permissions to be set for the folder.
Returns Promise<void>
-
Folder located in an app