> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/flow/tutorials/components/timeline/perform-actions-on-selected-tasks.md). Agents can also search and read this documentation through its [MCP server](https://docs.avonnicomponents.com/~gitbook/mcp).

# Perform actions on selected tasks

Let a user tick open tasks on a Timeline and close them all in one click, with the Selected Item Names output, Get Records and Update Records.

After a site visit at Harbor Point Logistics, a service manager has six open follow-ups on the account and wants to close the ones that are done. In this screen flow, the **Avonni Timeline** shows the open tasks with a checkbox on each one. The manager ticks the finished ones, clicks **Next**, confirms, and the flow marks them all `Completed`.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FOYWSwRmhzUg5HRju1b7u%2Ftimeline-perform-actions-on-selected-tasks-result.png?alt=media" alt="Avonni Timeline listing six open tasks of Harbor Point Logistics, each with a checkbox, two of them ticked" width="460"><figcaption><p>Each open task has a checkbox, and the ticked ones go to the next screen.</p></figcaption></figure>

## Before you start

* Your screen flow has a `recordId` input variable (Text, available for input) and runs on the Account record page. If not, follow [How to pass your current RecordID in your screen flow](https://docs.avonnicomponents.com/flow/tutorials/tips-and-tricks/how-to-pass-your-current-recordid-in-your-screen-flow.md).
* The account has open Tasks (**Status** other than `Completed`).
* If you have never set up a Timeline, [Display Tasks](https://docs.avonnicomponents.com/flow/tutorials/components/timeline/display-tasks.md) explains every mapping used below.

## Steps

{% stepper %}
{% step %}

### Get the account's open tasks

Add a **Get Records** element before the first screen.

1. Label it `Get Open Tasks` (API name `Get_Open_Tasks`). **Object**: **Task**.
2. Conditions: **Related To ID** (`WhatId`) Equals `{!recordId}`, AND `IsClosed` Equals `{!$GlobalConstant.False}`.
3. **How Many Records to Store**: **All records**.

No need to sort here: the Timeline orders items by **Start Date** itself, newest first by default.
{% endstep %}

{% step %}

### Show the tasks on a Timeline with checkboxes

1. Add a Screen element labelled `Review Open Tasks` and drag the **Avonni Timeline** onto it from the Screen components panel. Set its **API Name** to `OpenTasksTimeline`.
2. Click **Open Component Builder**. In the **Header** section, set **Title** to `Open follow-ups`.
3. In **Data Source**, choose **Variable** and pick `Get_Open_Tasks` in **Items Collection**.
4. In **Data Mappings**, map **Title** to `Subject`, **Description** to `Description` and **Start Date** to `ActivityDate`, and set **Avatar** > **Icon Name** to `standard:task`.
5. **Has Checkbox** starts as a field picker. Click the mode icon at the right of its label to turn it into a toggle, then switch the toggle on: every item gets a checkbox. Leave **Key Field** on its default, `Id`.

The **Key Field** matters here: it is the value the Timeline returns for each ticked item. With `Id`, you get Task IDs, which is exactly what the next Get Records needs.
{% endstep %}

{% step %}

### Get the tasks the user ticked

After the screen, add a second **Get Records** element.

1. Label it `Get Selected Tasks` (API name `Get_Selected_Tasks`). **Object**: **Task**.
2. Condition: `Id` In `{!OpenTasksTimeline.selectedItemNames}`. In the resource picker, it is **Selected Item Names** under the `OpenTasksTimeline` component.
3. **How Many Records to Store**: **All records**.

{% hint style="info" %}
The component also returns **Selected Items**, the ticked records themselves. It holds only the fields the first Get Records fetched, so the second Get Records is the safer source for an update.
{% endhint %}
{% endstep %}

{% step %}

### Ask the user to confirm

1. Add an **Assignment** element: a Number variable `SelectedCount` **Equals Count** `{!Get_Selected_Tasks}`.
2. Add a Screen element labelled `Confirm` with a **Display Text**: `{!SelectedCount} task(s) will be marked Completed. Click Finish to confirm.`

This is the second screen of the flow. A user who clicks **Previous** gets back to the Timeline.
{% endstep %}

{% step %}

### Mark the tasks Completed

1. Add a **Loop** over `{!Get_Selected_Tasks}`.
2. Inside the loop, add an **Assignment**: `{!Loop_Task.Status}` Equals `Completed`, then add `{!Loop_Task}` to a Task record collection variable `TasksToClose`.
3. After the loop, add **Update Records**: **Use the IDs and all field values from a record or record collection**, and select `{!TasksToClose}`.
   {% endstep %}

{% step %}

### Save and test

Click **Done**, save and activate the flow, and add it to the Account record page. Open Harbor Point Logistics: the Timeline lists the open tasks, each with a checkbox. Tick two, click **Next**: the Confirm screen reads `2 task(s) will be marked Completed`. Click **Finish**, then reopen the flow: the two tasks are gone from the list, because they are now `Completed`.
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>No checkbox appears on the items</summary>

**Has Checkbox** is still a field picker, or its toggle is off. Click the mode icon next to its label and switch the toggle on.

</details>

<details>

<summary>Get Selected Tasks returns nothing</summary>

* The user did not tick anything before clicking **Next**. Add a Decision after the Get Records to handle an empty selection.
* **Key Field** was changed from `Id`, so **Selected Item Names** holds something other than Task IDs. Set it back.

</details>

## Related tutorials

* [Display Tasks](https://docs.avonnicomponents.com/flow/tutorials/components/timeline/display-tasks.md): the basic Timeline setup this page builds on.
* [Act on a timeline item](https://docs.avonnicomponents.com/flow/tutorials/components/timeline/act-on-a-timeline-item.md): open a flow or delete a task from a single item, without a second screen.
* [Search and filter a timeline](https://docs.avonnicomponents.com/flow/tutorials/components/timeline/search-and-filter-a-timeline.md): help the user find the right tasks before ticking them.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avonnicomponents.com/flow/tutorials/components/timeline/perform-actions-on-selected-tasks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
