> 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-create-events-by-dragging-in-the-avonni-calendar.md). Agents can also search and read this documentation through its [MCP server](https://docs.avonnicomponents.com/~gitbook/mcp).

# Create an event by dragging and save it

Let a dispatcher draw a time range on the Avonni Calendar and save it as a new Event, with the start and end already filled in from the drag.

A dispatcher sees a free slot on Thursday afternoon and wants to book a boiler inspection there. With **New Event Drag**, they draw the slot on the calendar, a form opens with the start and end already filled in, and the visit is saved as an Event.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FxnVajaETCRyliCt0xRT9%2Fcalendar-how-to-create-events-by-dragging-in-the-avonni-calendar-result.png?alt=media" alt="Avonni Calendar timeline for Thursday and Friday, November 19 and 20, 2026, with a blue New event block drawn on Michel Chartrand&#x27;s row from 2 PM to 4 PM"><figcaption><p>Drag across a free slot: the New event block follows the pointer until you release it.</p></figcaption></figure>

## Before you start

* A screen flow with the Avonni Calendar on a Screen element, showing Events. See [Calendar 101](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/calendar-101-tutorial.md).
* A second screen flow that creates the Event. It takes two Date/Time input variables, for example `startDateTime` and `endDateTime`, and uses a Create Records element.
* A **Query** data source if you want the new event to appear without reloading the page. See [Use a Query data source](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/using-a-query-data-source.md).

## Steps

{% stepper %}
{% step %}

### Add the New Event Drag interaction

1. Open the Calendar in the Component Builder and go to the **Interactions** tab.
2. Under **New Event Drag**, add an interaction.
3. Set **Type** to **Open Flow Dialog** and pick your create flow in **API Name**. The list shows each flow by its label.

Until this interaction exists, users cannot draw new events on the calendar.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FBo61hecJ3KNpJliXGVSl%2Fcalendar-how-to-create-events-by-dragging-in-the-avonni-calendar-interaction.png?alt=media" alt="Calendar Interactions tab with New Event Drag set to Open Flow Dialog, and its popover with API Name New visit, Input Variables startDateTime and endDateTime, Modal Header New visit, Modal Size Small and On Finish Refresh Query" width="320"><figcaption><p>New Event Drag opens the create flow and passes it the drawn start and end.</p></figcaption></figure>
{% endstep %}

{% step %}

### Pass the drawn range to the flow

In **Input Variables**, add two rows:

| Name            | Type      | Value               |
| --------------- | --------- | ------------------- |
| `startDateTime` | Date/Time | **Start Date Time** |
| `endDateTime`   | Date/Time | **End Date Time**   |

**Start Date Time** and **End Date Time** are the start and end of the range the user drew. In the create flow, use the two variables for `StartDateTime` and `EndDateTime` on the new Event.

{% hint style="info" %}
The resource row is not passed. Let the dispatcher pick the technician (`OwnerId`) in the create flow.
{% endhint %}
{% endstep %}

{% step %}

### Reload the calendar after the save

In **On Finish**, add a **Refresh Query** action. The calendar reloads its events, and the new visit appears in its slot. **Refresh Query** is only offered with a **Query** data source.
{% endstep %}

{% step %}

### Decide whether past slots are allowed

By default, users can draw events in the past. To stop that, turn on **Prevent Past Event Creation** at the top of the **Interactions** tab. See [Block past dates and limit working hours](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/block-past-dates-and-limit-working-hours.md).
{% endstep %}

{% step %}

### Save and test

Save the screen flow and run it (the drag does nothing in the Component Builder preview). Drag across two hours on Thursday afternoon. The dialog opens with the start and end of that range, and after you save, the new Event appears on the calendar.

<figure><img src="https://27923732-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1FUd4apB9YHgCEMUFbVb%2Fuploads%2FAz2pMjQJLZ3SpCKx1EPU%2Fcalendar-how-to-create-events-by-dragging-in-the-avonni-calendar-dialog.png?alt=media" alt="New visit dialog with Subject, Technician, Start Nov 19, 2026 2:00 PM and End Nov 19, 2026 4:00 PM"><figcaption><p>The create flow opens with the start and end of the drawn range already filled in.</p></figcaption></figure>
{% endstep %}
{% endstepper %}

To open the standard New Event page instead of a flow, set **Type** to **Navigate**, **Page Reference Type** to **Object Page**, **Object Api Name** to `Event`, **Action Name** to `new`, and map `StartDateTime` and `EndDateTime` in **Prefilled Values** to **Start Date Time** and **End Date Time**.

## Troubleshooting

<details>

<summary>Nothing happens when I drag on the calendar</summary>

Check that a **New Event Drag** interaction exists, and run the flow: drags are ignored in the Component Builder preview. If **Prevent Past Event Creation** is on, drags in the past are ignored too.

</details>

<details>

<summary>The event is saved but does not show on the calendar</summary>

Add **Refresh Query** in **On Finish**. Also check that the new Event matches the data source filters, for example the same owners and date range.

</details>

## Related tutorials

* [Reschedule events with drag and drop](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/how-to-reschedule-events-with-drag-and-drop.md): move an existing visit and save the new time.
* [Add a New Event button to the header](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/how-to-add-a-new-event-button-to-the-avonni-calendar-header.md): create events without dragging.
* [Add actions to events](https://docs.avonnicomponents.com/flow/tutorials/components/calendar/how-to-customize-the-right-click-menu.md): create an event from a right-click on an empty spot.


---

# 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-create-events-by-dragging-in-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.
