> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GetTaskExt

> GetTaskExt method in the ABBYY FlexiCapture Web Services API selects the highest-priority task by stage type and opens it for processing.

## What it does

Selects the task with the highest priority and opens it for processing. The selected task is locked, which means it cannot be opened by other users. The set of available batches can be restricted.

<Info>
  A task must be opened before any actions on the task can be performed.
</Info>

## Definition

```csharp theme={null}
int GetTaskExt(int sessionId, int projectId, int stageType, bool onlyPreprocessedTask, bool onlyPrivateBatches);
```

## Parameters

| Name                   | Type   | Description                                                                                                                                                                  |
| ---------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sessionId`            | `int`  | The ID of the connection to the Application Server.                                                                                                                          |
| `projectId`            | `int`  | Project ID.                                                                                                                                                                  |
| `stageType`            | `int`  | The ID of the stage type. For possible values, see [ProcessingStageType](/flexi-capture/api/structures/t-processing-stage-type).                                             |
| `onlyPreprocessedTask` | `bool` | A flag that determines which tasks to select from. `True` selects only pre-processed tasks. `False` selects from all tasks.                                                  |
| `onlyPrivateBatches`   | `bool` | A flag that determines the set of available batches. `True` makes available only batches that belong to the current user or user group. `False` makes all batches available. |

## Returned value

| Type  | Description |
| ----- | ----------- |
| `int` | Task ID.    |
