System objects are database entries. They are either app items (ApplicationItem) or base system objects (UserItem, FileItem, ImageItem). Each object is described with a set of fields (ItemData), where the field code is mapped to its type. The objects also have a base set of fields BaseItemData. Each object contains a description of its fields ( fields property) as well as the value object of these fields (data property). A field’s description depends on its type.

References to objects

For all the objects there is also a reference object ItemRef, which is used to get the object itself. For example, the base set of fields of any object includes a reference to the object’s author __createdBy; to get the author object you have to request:

const author = await Context.data.__createdBy.fetch();

Every reference has the fetch method which is used to get the object itself .

Users

User (UserItem) is a system object with a set of UserData fields. To reference a user, the UserItemRef type object is used. At the moment, users cannot be created or modified from a script.
Let’s say a process is run for the order app item, and it is necessary to set a task for the author of this app item. In this case we recommend using the dynamic swimlane and store the app item’s author in the author variable:

const order = await Context.data.order.fetch();
Context.data.author = order.data.__createdBy; 

For the user objects and its reference, the UserItemRef.getChiefs method is available for getting the user’s superior. If we need to get the superiors of the user from the
previous example, here is how we can do it:

Context.data.chiefs = await Context.data.author.getChiefs();

Files

A file (FileItem) is a system object with a set of FileData fields. To reference a file, the FileItemRef type object is used. At the moment you cannot modify files from a script. The FileField.create method allows you to create files in the process instance folder

const fileRq = await  fetch(`https://jpeg.org/images/jpegsystems-home.jpg`)
const buf = await  fileRq.arrayBuffer() 
const file = await Context.fields.file.create('home.jpg',  buf) 

The FileField.createFromLink method allows you to upload files from external sources to the process instance folder

const  file = await Context.fields.file.createFromLink('home.jpg',  `https://jpeg.org/images/jpegsystems-home.jpg`)

The methods FileItem.getDownloadUrl and FileItemRef.getDownloadUrl allow you to
get the file download link

const url = await  file.getDownloadUrl();

App items

An app item (ApplicationItem) consists of the fields of this app. If there is an App field in the process context, this field will store one reference (ApplicationItemRef) or an array of such references (if the
“Many-to-many” option is selected). To get app objects use references from other objects and Global constants. You can read more
about working with apps in the corresponding section .

Type aliases

Based

Based: T & BaseItemData