> 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/assigning-multiple-source-collection-to-the-timeline.md).

# Assigning multiple source collections to the Timeline

Combine an account's Tasks, Events and Cases in one Avonni Timeline with the SObject Collection to Activity Timeline Items action, each with its own icon.

An account manager preparing a quarterly review with Harbor Point Logistics wants one chronological view of everything: the calls and emails (Tasks), the site visits (Events) and the support Cases. The **Avonni Timeline** reads one collection, so the flow first merges the three with the **SObject Collection to Activity Timeline Items** action, then the Timeline displays the result.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FSK6SkMyTJTWgY6oVpWXe%2Ftimeline-assigning-multiple-source-collection-to-the-timeline-result.png?alt=media" alt="One Avonni Timeline mixing the account&#x27;s Tasks, Events and Cases, each with its own icon" width="440"><figcaption><p>Tasks, Events and Cases of one account in a single timeline.</p></figcaption></figure>

## Before you start

* A screen flow with a text input variable `recordId`, launched from the Account record page with the record ID passed in. [How to pass your current RecordID in your screen flow](/flow/tutorials/tips-and-tricks/how-to-pass-your-current-recordid-in-your-screen-flow.md) shows how.
* For a single object, you do not need this page: [Display Tasks](/flow/tutorials/components/timeline/display-tasks.md) or [Show a record history with a query](/flow/tutorials/components/timeline/show-a-record-history-with-a-query.md) is simpler.

## Steps

{% stepper %}
{% step %}

### Get the records of each object

Add three **Get Records** elements, each storing **All records**:

| Element       | Object | Condition                              |
| ------------- | ------ | -------------------------------------- |
| `Get_Tasks`   | Task   | **Related To ID** Equals `{!recordId}` |
| `Get_Events`  | Event  | **Related To ID** Equals `{!recordId}` |
| `Get_Cases`   | Case   | **Account ID** Equals `{!recordId}`    |
| {% endstep %} |        |                                        |

{% step %}

### Add the action

1. After the three Get Records, add an **Action** element.
2. Filter the actions on the **Avonni** category and pick **SObject Collection to Activity Timeline Items**.
3. Give it a label, for example `Build Timeline Items`.
   {% endstep %}

{% step %}

### Map each collection

For each object, click **Add Collection**, pick the collection in **Collection**, then fill its mappings. The action takes up to 10 collections.

| Mapping         | `Get_Tasks`     | `Get_Events`     | `Get_Cases`     |
| --------------- | --------------- | ---------------- | --------------- |
| **Title**       | `Subject`       | `Subject`        | `Subject`       |
| **Description** | `Description`   | `Description`    | `Description`   |
| **Icon Name**   | `standard:task` | `standard:event` | `standard:case` |
| **Date**        | `ActivityDate`  | `StartDateTime`  | `CreatedDate`   |
| **Fields**      | **Status**      | **Location**     | **Status**      |

For Tasks and Events, the action prefills **Title**, **Description**, **Icon Name** and **Date** as in this table; for Cases, fill them yourself. Use **Description** for the second line: the action has no Subtitle mapping. **Key Field** sits under each collection's **Advanced Options** link and defaults to the record's `Id`: keep it.

{% hint style="info" %}
To link each item title to its record, set **URL** to `/{{Record.Id}}` in each collection. The record opens in the same tab (**Target** **Self**, the default); pick **Blank** to open it in a new tab.
{% endhint %}
{% endstep %}

{% step %}

### Store the action's output

The action returns a collection of `avcmpbuilder__ActivityTimelineItem`, the item type the Timeline reads.

1. The action stores its output on its own: **View Output Resources** lists it as `output`, and the Timeline can read it as is. To give it a clearer name, select **Manually assign variables (advanced)**, just below, and store the output in a new variable.
2. If you assign it manually, click **New Resource**: **Variable**, API name `TimelineItems`, **Data Type** **Apex-Defined**, **Allow multiple values (collection)** checked, **Apex Class** `avcmpbuilder__ActivityTimelineItem`.
3. Click **Done**.
   {% endstep %}

{% step %}

### Point the Timeline at the merged collection

1. Add a **Screen** after the action and drag the **Avonni Timeline** onto it.
2. Click **Open Component Builder**.
3. In **Data Source**, click **Variable** and pick `TimelineItems` (or the action's automatic output) in **Items Collection**.

The items are already shaped by the action, so the **Data Mappings** section stays empty: change titles, icons or fields in the action, not in the Timeline.
{% endstep %}

{% step %}

### Save and test

Click **Done**, save the flow and open it from an Account record page. One timeline lists the account's Tasks, Events and Cases together, newest first, each with its own icon: a task, a calendar event or a case. To split them by month, see [Group a timeline by month](/flow/tutorials/components/timeline/group-a-timeline-by-month.md).
{% endstep %}
{% endstepper %}

## Troubleshooting

<details>

<summary>TimelineItems is not listed in Items Collection</summary>

The variable must be a collection (**Allow multiple values (collection)** checked) of the Apex class `avcmpbuilder__ActivityTimelineItem`. A single Apex-defined variable, or a variable of another class, is not offered.

</details>

<details>

<summary>One object is missing from the timeline</summary>

A collection is only converted when it is picked in **Collection** and has mappings. Check both in the action, then check that its Get Records finds records for this account.

</details>

<details>

<summary>In horizontal orientation every icon is grey</summary>

On package versions before 6.33.0, the horizontal view ignores the **Icon Name** set by this action, while the vertical view shows it. Upgrade, or use the workaround in [Create a horizontal activity timeline](/flow/tutorials/components/timeline/create-a-horizontal-activity-timeline.md).

</details>

## Related tutorials

* [SObject Collection to Activity Timeline Items](/flow/actions/data-manipulation-and-transformation/sobject-collection-to-activity-timeline-items.md): every input of the action.
* [Display Tasks](/flow/tutorials/components/timeline/display-tasks.md): one object, mapped in the Timeline itself.
* [Create a horizontal activity timeline](/flow/tutorials/components/timeline/create-a-horizontal-activity-timeline.md): the same items on a date axis.


---

# 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/assigning-multiple-source-collection-to-the-timeline.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.
