- Home [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
- Getting started
- Use cases
-
API
-
Object types
- DispositionType
- ProcessInstanceState
- ProcessTaskState
- ApplicationItemRegistration
- ApplicationProjectItem
- ApplicationProjectItemRef
- ApplicationProjectPlanElementItem
- ApplicationProjectPlanElementItemRef
- BaseApplicationItem
- BaseApplicationItemRef
- BaseItem
- BaseItemData
- CurrentUserItem
- DirectoryData
- DirectoryItem
- EmployeeItemData
- EmployeeItemParams
- EmployeeItemProcesses
- FileData
- FileItem
- FileItemRef
- FileVersionData
- FileVersionItem
- ImageData
- ImageItem
- ImageItemRef
- InstanceAddr
- Item
- ItemData
- ItemRef
- MailMessageData
- MailMessageItem
- MailMessageItemRef
- OrganisationStructureData
- OrganisationStructureItem
- OrganisationStructureItemRef
- ParamsItem
- ProcessInstanceData
- ProcessInstanceItem
- ProcessInstanceItemRef
- ProcessTaskData
- ProcessTaskItem
- ProcessTaskItemRef
- ProcessTemplate
- ProcessTimer
- ReminderData
- ReminderItem
- ReplacementData
- ReplacementItem
- StatusHistoryData
- StatusHistoryItem
- StatusHistoryItemRef
- TaskItemExit
- UserData
- UserGroupData
- UserGroupItem
- UserGroupItemRef
- UserItem
- UserItemRef
- ApplicationItem
- ApplicationItemRef
- Data types
- Global constants
- Work with apps
- Web requests
- Access permissions
- Document flow
- Live Chats
- “Code” widget
- Signatures
- Business calendars
- Integration with IP telephony
- Integration with email marketing services
-
Object types
Process task object
Type parameters
Context: ProcessContext
I: Item<ItemData>
I: Item<ItemData>
Hierarchy
Properties
Readonly code
App code of the URL’s target (the app’s code).
Readonly data
Values of object’s fields.
Readonly fields
Description of the object’s fields.
Readonly id
ID of the URL’s target.
Readonly namespace
Namespace of the URL target (the code of the workspace that the app belongs to).
Methods
changeDueDate
Change the task due date.
Here is how to set a different due date for a task:
try { // Get the comment from the process context const comment = Context.data. comment; // Get the task ID from the process context const taskUUID = Context.data.taskid; let task = await System.processes._searchTasks(). where(x => x.__id.eq(taskUUID)).first(); // If the task does not exist, an error is displayed if (!task) { throw new Error('Задача не найдена'); } // Get the current date let newDueDate = new Datetime(); // Add one day newDueDate = newDueDate.addDate(0, 0, 1); await task.changeDueDate(newDueDate, comment); } catch (error) { // If the process has already finished, the exception can be processed }
Parameters
dueDate: TDatetime
Optional comment: undefined | string
Returns Promise<void>
createReminder
Create a reminder.
Example of searching for a task and creating a reminder for it:
// Get the tast object let task = await System.processes. _searchTasks().where(x => x.__id.eq(taskUUID)).first(); // If the task object is not found, stop the script execution if (!task) { return; } // Get the current user const user = await System.users.getCurrentUser(); // Get the current date and add one day // The time zone is taken from the field `System.timezones.current` let dateReminder = new Datetime(); dateReminder = dateReminder.add(new Duration(1, 'days')) // Create a reminder for the task on the next day await task.createReminder( dateReminder, user);
Parameters
date: TDatetime
user: UserItemRef
Returns Promise<ReminderItem>
Reminder.
fetch
Request complete data of a reference object.
Returns Promise<ProcessTaskItem<Context>>
getExits
Get possible task transitions.
Here is how to search for a task and finish it:
try { // Get the task object let task = await System.processes._searchTasks(). where(x => x.__id.eq(taskUUID)).first(); // If the task object is not found, the execution of the script finishes if (!task) { return; } // Get task transitions const exits = await task.getExits(); // Finish the task // Pass the transition’s ID and the form’s data await task.submitTask(exits[0].id, {comment: 'Task completed'}); } catch (e) { // If the process is already finished, the exception is processed }
Returns Promise<TaskItemExit[]>
getPerformers
The method returns the list of task executors.
const instance = await task.getPerformers();
Returns Promise<UserItem[]>
Users who are executors of the task.
getProcessInstance
The method returns a process object.
const instance = await task.getProcessInstance();
Returns Promise<ProcessInstanceItem<Context>>
The process that the task is started from.
normalize
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
reassign
Reassign a task to one or more new executors.
The reason for reassigning the task is written to the task’s activity stream. Review and approval tasks as well as system tasks are assigned to the first user in the list of new executors. If the corresponding process instance or the task is already finished, the method throws an exception.
In the example, we reassign a task using its ID from the context to one new executor.
async function reassign(): Promise<void> { // Getting the task ID for reassigning from the process context const taskID = Context.data.TaskForReassignUUID; // Searching for the task const task = await Application.processes._searchTasks().where(x => x. __id.eq(taskID)).first(); // Getting the user from the context const user = Context.data.NewPerformer; const comment = 'Replacing the executor'; await task.reassign(user, comment); }
In the second example, we reassign a task using its ID from the context to users from a group.
async function reassignMany(): Promise<void> { // Getting the task ID for reassigning from the process context const taskID = Context.data.TaskForReassignUUID; // Searching for the task const task = await Application.processes._searchTasks().where(x => x. __id.eq(taskID)).first(); // Getting the user group ID from the context const userGroupID = Context.data.groupUUID; // Searching for the user group const userGroup = await System.userGroups.search().where(x => x.__id.eq(userGroupID)).first(); const newPerformers = <UserItemRef[] >await userGroup.users(); const comment = 'Reassigning to several executors'; await task.reassign(newPerformers, comment); }
Parameters
user: UserItemRef | UserItemRef[]
Optional comment: undefined | string
Returns Promise<void>
submitTask
The method finishes a task.
Here is how to search for a task and finish it:
try { // Get the task object let task = await System.processes._searchTasks(). where(x => x.__id.eq(taskUUID)).first(); // Get task transitions const exits = await task.getExits(); // Pass the transition’s ID and the form’s data await task.submitTask(exits[0].id, {comment: 'Task completed'}); } catch (e) { // If the process is already finished, the exception is processed }
Parameters
exitID: string
Optional data: Context
Returns Promise<void>
Properties
Methods