> For the complete documentation index, see [llms.txt](https://docs.visualyze.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.visualyze.ai/getting-started/human-tasks/advanced-topics.md).

# Advanced Topics

## Getting the Tasks in Workflow

To retrieve tasks assigned to the logged-in user in a workflow, you can use the **Get Tasks** activity. This activity allows you to fetch tasks based on specific criteria. Here's how you can use it:

1. Drag and drop the **Get Tasks** activity into your workflow.
2. Configure the properties of the **Get Tasks** activity:
   * Set the **Status** property to include the task statuses you want to retrieve, such as **Done** and **Partially Done**.
   * Optionally, if you want to filter tasks from a specific task group, specify the task group name in the **Task Group Name** property.
3. Connect the **Get Tasks** activity to the subsequent activities in your workflow to process the retrieved tasks.
4. The output of the **Get Tasks** activity includes two properties:
   * The **Tasks** property contains a list of all the tasks retrieved. You can access individual tasks and their properties using this property.
   * The **Task Count** property indicates the total number of tasks retrieved.

By using the **Get Tasks** activity with the appropriate configuration, you can retrieve tasks assigned to the logged-in user, filter them based on status and task group if needed, and continue processing the tasks in your workflow. The tasks will be sorted in **descending order based on their last updated date**.

## Retrieving Data from Tasks

To retrieve data from a task, you can use the **Assign activity** in your automation workflow. Assuming you have the task saved in a variable named `Task`, you can follow these steps:

{% hint style="warning" %}
You must be familiar with Assign activity and For Each activity.
{% endhint %}

#### **Case 1**

Get value from a field named `InvoiceNumber` from the only dependency of a task:&#x20;

Use the following expression in the Assign activity: `Task.Dependency.Data["InvoiceNumber"].Value` or `Task.Dependencies[0].Data["InvoiceNumber"].Value`.

#### **Case 2**

Get value from a field named `InvoiceDate` from the **second dependency** of a task:

Use the following expression in the Assign activity: `Task.Dependencies[1].Data["InvoiceDate"].Value`.

#### Case 3

Get value from a column named `Quantity` from a table named `LineItems` in the **only dependency** of a task:&#x20;

This can be achieved in two stages:

1. Assign the table named `LineItems` to a variable, let's say `LineItems`, using the following expression in an Assign activity: `Task.Dependencies[0].Data["LineItems"].Value`.
2. Add a **Foreach Loop activity** (along with the corresponding **End Loop activity**) after the Assign activity. Set the `LineItems` variable as the collection property. On each iteration, the current value of the loop will represent each row of the `LineItems` table.
3. Within the loop, add another Assign activity. If the current value variable is named `Item`, use the expression `Item["Quantity"].Value` to retrieve the value from the `Quantity` column.

By following these steps and customizing the expressions as per your task structure, you can retrieve specific data from a task in your automation workflow.

## Best Practices for Designing Human Tasks

\
When designing human tasks, it's important to follow best practices to ensure efficiency and clarity. Here are some recommendations:

#### Naming Conventions

Use descriptive and meaningful names for field names, table names, and other components. Avoid spaces and use a consistent naming convention (e.g., ReportId, AccountNo). This helps improve readability and maintainability.

#### Task Group Name

Assign the same task group name to tasks created with the same extractor definition. This ensures that a workflow designed for a specific task group can be applied to all tasks within that group. Avoid using the same group name for tasks created using different extractor definitions.

#### Task Status

Set the recommended task status when saving the task to provide clear information about its progress:

* If the task is partially completed, set the status to **Partially Done**.
* If the task is fully completed, set the status to **Done**.
* If the task requires further attention or additional information, put it on **On Hold**.
* If the task should never have been created or is no longer needed, change the status to **Cancelled**.
* If the task has been processed and no longer requires any attention, change the status to **Verified**.

#### Remarks

Use clear and informative messages in remarks. Provide relevant details, updates, or instructions to effectively communicate with the team. Well-documented remarks facilitate collaboration and provide context for task completion.

By following these best practices, you can ensure that your human tasks are well-structured, properly categorized, and easily manageable within your workflow.
