Tasks
Service for managing UiPath Action Center
Tasks are task-based automation components that can be integrated into applications and processes. They represent discrete units of work that can be triggered and monitored through the UiPath API. UiPath Action Center Guide
Usage¶
Prerequisites: Initialize the SDK first - see Getting Started
import { Tasks } from '@uipath/uipath-typescript/tasks';
const tasks = new Tasks(sdk);
const allTasks = await tasks.getAll();
Methods¶
getAll()¶
getAll<T>(options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<TaskGetResponse> : NonPaginatedResponse<TaskGetResponse>>;
Gets all tasks across folders with optional filtering
Type Parameters¶
| Type Parameter | Default type |
|---|---|
T extends TaskGetAllOptions |
TaskGetAllOptions |
Parameters¶
| Parameter | Type | Description |
|---|---|---|
options? |
T |
Query options including optional folderId, asTaskAdmin flag and pagination options |
Returns¶
Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<TaskGetResponse> : NonPaginatedResponse<TaskGetResponse>>
Promise resolving to either an array of tasks NonPaginatedResponse
Example¶
// Standard array return
const allTasks = await tasks.getAll();
// Get tasks within a specific folder
const folderTasks = await tasks.getAll({
folderId: 123
});
// Get tasks with admin permissions
// This fetches tasks across folders where the user has Task.View, Task.Edit and TaskAssignment.Create permissions
const adminTasks = await tasks.getAll({
asTaskAdmin: true
});
// Get tasks without admin permissions (default)
// This fetches tasks across folders where the user has Task.View and Task.Edit permissions
const userTasks = await tasks.getAll({
asTaskAdmin: false
});
// First page with pagination
const page1 = await tasks.getAll({ pageSize: 10 });
// Navigate using cursor
if (page1.hasNextPage) {
const page2 = await tasks.getAll({ cursor: page1.nextCursor });
}
// Jump to specific page
const page5 = await tasks.getAll({
jumpToPage: 5,
pageSize: 10
});
getById()¶
Gets a task by ID IMPORTANT: For form tasks, folderId must be provided.
Parameters¶
| Parameter | Type | Description |
|---|---|---|
id |
number |
The ID of the task to retrieve |
options? |
BaseOptions |
Optional query parameters |
folderId? |
number |
Optional folder ID (REQUIRED for form tasks) |
Returns¶
Promise<TaskGetResponse>
Promise resolving to the task TaskGetResponse
Example¶
// Get a task by ID
const task = await tasks.getById(<taskId>);
// Get a form task by ID
const formTask = await tasks.getById(<taskId>, <folderId>);
// Access form task properties
console.log(formTask.formLayout);
create()¶
Creates a new task
Parameters¶
| Parameter | Type | Description |
|---|---|---|
options |
TaskCreateOptions |
The task to be created |
folderId |
number |
Required folder ID |
Returns¶
Promise<TaskCreateResponse>
Promise resolving to the created task TaskCreateResponse
Example¶
import { TaskPriority } from '@uipath/uipath-typescript';
const task = await tasks.create({
title: "My Task",
priority: TaskPriority.Medium
}, <folderId>); // folderId is required
assign()¶
assign(options:
| TaskAssignmentOptions
| TaskAssignmentOptions[]): Promise<OperationResponse<
| TaskAssignmentOptions[]
| TaskAssignmentResponse[]>>;
Assigns tasks to users
Parameters¶
| Parameter | Type | Description |
|---|---|---|
options |
| TaskAssignmentOptions | TaskAssignmentOptions[] |
Single task assignment or array of task assignments |
Returns¶
Promise<OperationResponse<
| TaskAssignmentOptions[]
| TaskAssignmentResponse[]>>
Promise resolving to array of task assignment results TaskAssignmentResponse
Example¶
// Assign a single task to a user by ID
const result = await tasks.assign({
taskId: <taskId>,
userId: <userId>
});
// Or using instance method
const task = await tasks.getById(<taskId>);
const result = await task.assign({
userId: <userId>
});
// Assign a single task to a user by email
const result = await tasks.assign({
taskId: <taskId>,
userNameOrEmail: "user@example.com"
});
// Assign multiple tasks
const result = await tasks.assign([
{ taskId: <taskId1>, userId: <userId> },
{ taskId: <taskId2>, userNameOrEmail: "user@example.com" }
]);
reassign()¶
reassign(options:
| TaskAssignmentOptions
| TaskAssignmentOptions[]): Promise<OperationResponse<
| TaskAssignmentOptions[]
| TaskAssignmentResponse[]>>;
Reassigns tasks to new users
Parameters¶
| Parameter | Type | Description |
|---|---|---|
options |
| TaskAssignmentOptions | TaskAssignmentOptions[] |
Single task assignment or array of task assignments |
Returns¶
Promise<OperationResponse<
| TaskAssignmentOptions[]
| TaskAssignmentResponse[]>>
Promise resolving to array of task assignment results TaskAssignmentResponse
Example¶
// Reassign a single task to a user by ID
const result = await tasks.reassign({
taskId: <taskId>,
userId: <userId>
});
// Or using instance method
const task = await tasks.getById(<taskId>);
const result = await task.reassign({
userId: <userId>
});
// Reassign a single task to a user by email
const result = await tasks.reassign({
taskId: <taskId>,
userNameOrEmail: "user@example.com"
});
// Reassign multiple tasks
const result = await tasks.reassign([
{ taskId: <taskId1>, userId: <userId> },
{ taskId: <taskId2>, userNameOrEmail: "user@example.com" }
]);
unassign()¶
unassign(taskId: number | number[]): Promise<OperationResponse<
| TaskAssignmentResponse[]
| {
taskId: number;
}[]>>;
Unassigns tasks (removes current assignees)
Parameters¶
| Parameter | Type | Description |
|---|---|---|
taskId |
number | number[] |
Single task ID or array of task IDs to unassign |
Returns¶
Promise<OperationResponse<
| TaskAssignmentResponse[]
| {
taskId: number;
}[]>>
Promise resolving to array of task assignment results TaskAssignmentResponse
Example¶
// Unassign a single task
const result = await tasks.unassign(<taskId>);
// Or using instance method
const task = await tasks.getById(<taskId>);
const result = await task.unassign();
// Unassign multiple tasks
const result = await tasks.unassign([<taskId1>, <taskId2>, <taskId3>]);
complete()¶
complete(options: TaskCompletionOptions, folderId: number): Promise<OperationResponse<TaskCompletionOptions>>;
Completes a task with the specified type and data
Parameters¶
| Parameter | Type | Description |
|---|---|---|
options |
TaskCompletionOptions |
The completion options including task type, taskId, data, and action |
folderId |
number |
Required folder ID |
Returns¶
Promise<OperationResponse<TaskCompletionOptions>>
Promise resolving to completion result TaskCompleteOptions
Example¶
// Complete an app task
await tasks.complete({
type: TaskType.App,
taskId: <taskId>,
data: {},
action: "submit"
}, <folderId>); // folderId is required
// Complete an external task
await tasks.complete({
type: TaskType.External,
taskId: <taskId>
}, <folderId>); // folderId is required
getUsers()¶
getUsers<T>(folderId: number, options?: T): Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<UserLoginInfo> : NonPaginatedResponse<UserLoginInfo>>;
Gets users in the given folder who have Tasks.View and Tasks.Edit permissions Returns a NonPaginatedResponse with data and totalCount when no pagination parameters are provided, or a PaginatedResponse when any pagination parameter is provided
Type Parameters¶
| Type Parameter | Default type |
|---|---|
T extends TaskGetUsersOptions |
TaskGetUsersOptions |
Parameters¶
| Parameter | Type | Description |
|---|---|---|
folderId |
number |
The folder ID to get users from |
options? |
T |
Optional query and pagination parameters |
Returns¶
Promise<T extends HasPaginationOptions<T> ? PaginatedResponse<UserLoginInfo> : NonPaginatedResponse<UserLoginInfo>>
Promise resolving to either an array of users NonPaginatedResponse