> 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/calendar/how-to-connect-multiple-data-sources-to-the-avonni-calendar.md). Agents can also search and read this documentation through its [MCP server](https://docs.avonnicomponents.com/~gitbook/mcp).

# Connect multiple data sources

Show visits and work orders on one Avonni Calendar by combining several record collections into one event collection with a flow action.

A dispatcher plans visits stored as `Event` records and repairs stored as `WorkOrder` records, and wants both on the same board. The Avonni Calendar reads one event collection, so the flow merges the two with the **SObject Collection to Scheduler Events** action, then hands the result to the calendar.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2F8DodWW01SNN3s1Lw5VxG%2Fcalendar-how-to-connect-multiple-data-sources-to-the-avonni-calendar-result.png?alt=media" alt="A Timeline week of three technicians where visits show in blue and work orders show in orange on the same rows"><figcaption><p>Visits and work orders on one calendar, each source in its own color.</p></figcaption></figure>

## Before you start

* You have built the calendar of the [Calendar 101](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/calendar-101-tutorial.md), with a Variable data source and the technicians as resources.
* You know how to create a resource and add an Action element in Flow Builder.

## Steps

{% stepper %}
{% step %}

### Get each set of records

Add one **Get Records** element per object, all storing **All records**:

1. **User**: the technicians, as in the 101 tutorial.
2. **Event**: the week's visits.
3. **Work Order**: the week's work orders, filtered on `StartDate`.
   {% endstep %}

{% step %}

### Create the variable that will hold every event

1. In the Toolbox, select **New Resource**.
2. Set **Resource Type** to **Variable** and give it an API name, for example `allTeamEvents`.
3. Set **Data Type** to **Apex-Defined** and select **Allow multiple values (collection)**.
4. In **Apex Class**, pick `avcmpbuilder__SchedulerEvent`.
   {% endstep %}

{% step %}

### Merge the collections with the flow action

1. Add an **Action** element after the Get Records elements and search for **SObject Collection to Scheduler Events**.
2. In the first **Collection** box, pick the Event collection. Under **Data Mappings**, set **Title** to **Subject**, **Resource Name** to **Assigned To ID**, **From** to **Start Date Time** and **To** to **End Date Time**.
3. Click **Add Collection** and pick the Work Order collection. Set **Title** to **Subject**, **Resource Name** to **Owner ID**, **From** to **Start Date** and **To** to **End Date**.
4. To give each kind its own color, open **Advanced Options** in each box and set **Color**, for example `#0176d3` for visits and `#fe9339` for work orders.
5. Store the action's output in `allTeamEvents`. In Flow Builder, this is under the action's advanced options, **Manually assign variables**.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FkfyCCIRkdcQyeNOgkh8M%2Fcalendar-how-to-connect-multiple-data-sources-to-the-avonni-calendar-action.png?alt=media" alt="The SObject Collection to Scheduler Events action in Flow Builder with two collections, Get Visits and Get Work Orders, each with its own Data Mappings" width="320"><figcaption><p>One action, one Collection box per source, each with its own mappings.</p></figcaption></figure>

The action takes up to ten collections. **Resource Name** must hold the same value as the resource **Key Field** (a User ID here), whatever the object.
{% endstep %}

{% step %}

### Point the calendar at the combined collection

1. Open the calendar in the Component Builder. In the **Data Source** section, select **Variable**.
2. In **Resources Collection**, pick the User collection, and map **Label** as in the 101 tutorial.
3. In **Events Collection**, pick `allTeamEvents`.

**Data Mappings** now lists only **Resources**: the title, resource, dates and color of each event were already set by the action.

{% hint style="warning" %}
The calendar takes one resource collection. To show people from two objects as rows, merge them into a single collection first.
{% endhint %}
{% endstep %}

{% step %}

### Save and test

Save the flow and run it with **Debug**. Each technician's row shows both their visits and their work orders, each with its own title and times: visits in blue, work orders in orange. For colors that follow a field instead of the object, see [Color-code calendar entries](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/how-to-color-code-calendar-entries-in-the-avonni-calendar.md).
{% endstep %}
{% endstepper %}

## Related tutorials

* [Calendar 101](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/calendar-101-tutorial.md): the Variable data source and the resource mappings this page builds on.
* [Use a Query data source](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/using-a-query-data-source.md): when one object is enough, skip the flow elements.
* [Troubleshoot resources and missing events](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/troubleshoot-resources-and-missing-events.md): when work orders land on an Empty row.

The action's inputs are listed on [SObject Collection to Scheduler Events](https://docs.avonnicomponents.com/flow/actions/data-manipulation-and-transformation/sobject-collection-to-scheduler-events.md).


---

# 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/calendar/how-to-connect-multiple-data-sources-to-the-avonni-calendar.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.
