> ## 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.

# GetTaskByStageIdExt

> GetTaskByStageIdExt method in the ABBYY FlexiCapture Web Services API selects the highest-priority task by stage IDs 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 GetTaskByStageIdExt(int sessionId, int projectId, int[] stageIds, bool onlyPreprocessedTask, bool onlyPrivateBatches);
```

## Parameters

| Name                   | Type    | Description                                                                                                                                                                  |
| ---------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sessionId`            | `int`   | The ID of the connection to the Application Server.                                                                                                                          |
| `projectId`            | `int`   | Project ID.                                                                                                                                                                  |
| `stageIds`             | `int[]` | The IDs of the stages to get tasks from.                                                                                                                                     |
| `stageID_count`        | `int`   | The number of stages.                                                                                                                                                        |
| `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.    |
