# Schedule Objects

A Schedule Object is a type of App Object with a pre-defined structure intended to capture all relevant information pertaining to a scheduled appointment. Schedule Objects are used in tandem with a [Scheduler Web Control](../../web-controls/scheduler-web-control); when a Schedule Object is associated with a scheduler, all relevant information collected by users from the scheduler will be automatically inserted into that Schedule Object in AirData.

## Schedule Structure

A Schedule Object must contain the following six properties:

* **session\_id** (`string`) - indicates the [Journey](../../concepts/journeys) that the appointment is associated with. This corresponds the Session ID (designated **session.id**) automatically assigned as a [session-level variable](../variable-namespaces) at [the start of each Journey](../standard-journey-data).
* **start\_time** (`DateTime`) - refers to the beginning date and time of the appointment.
* **end\_time** ( `DateTime`) - refers to the ending date and time of the appointment.
* **recurrence** (`number`)- indexes the block of time selected for the appointment. Count begins at 0 and on the first occurrence of a potential appointment window, as defined by the [Time Slots that make up the Availability Schedule](../../studio/builder-bar/schedules-builder) tied to the associated [Scheduler Web Control](https://github.com/airkit/airkit-docs/blob/master/docs/v18-0/scheduler-web-control.md-Scheduler-Web-Control).
* **calendar\_event\_id** (`string`) - serves as an identifier for the Time Slot (as defined in the [Calendar Builder](../../studio/builder-bar/schedules-builder) – note that this is _not_ the same as the selected block of time which is indicated by _**recurrence**_) that defined the selected appointment block.
* **calendar\_id** (`string`) - serves as an identifier for the particular instance of [Scheduler Web Control](https://github.com/airkit/airkit-docs/blob/master/docs/v18-0/scheduler-web-control.md-Scheduler-Web-Control) used to make the appointment. This becomes particularly relevant in cases a [Journey](../../concepts/journeys) contains multiple schedulers associated with the same Schedule Object.

## Application of Schedule Objects

To create a new Schedule Object, go to [AirData Builder](../../studio/builder-bar/airdata-builder) and:

1. Click the '+' icon to the right of the **App Objects** section in the Tree.
2. Select **Add Schedule** from the menu that appears.

Schedule Objects are used in tandem with a Scheduler Web Control, automatically saving selected appointments to AirData. Sometimes, it is useful to save that data locally as well, so that it can be easily be referenced at future points within the application flow. To do this:

1. Create a local variable in the [Variable Tree](../../studio/variable-tree). The Type of this variable should correspond to the Schedule Object. (The following example references a global variable called `appointment`.)

![](https://2093598723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2DgLBPTrwoEhWaU24LL%2Fuploads%2Fgit-blob-033514d0781d5eab72f30ed890b1cc1913d9bfbb%2Fschedule-objects-v180-0.png?alt=media)

2. Examine the Scheduler Web Control and toggle to the **Actions** tab in the Inspector. Use the \*\*Set Variable \*\* Action to set the Schedule Object variable to the value associated with the Scheduler Web Control. Within the Event associated with the Scheduler Web Control, that's accessible as `value`.

![](https://2093598723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FC2DgLBPTrwoEhWaU24LL%2Fuploads%2Fgit-blob-399d75b90264b8af4b8b3031296d67c94d0c308f%2Fschedule-objects-v180-1.png?alt=media)

3. Reference this Schedule Object variable as you would any other object, using dot notation to reference individual properties. For instance, say you want to remind users of the appointment time they selected, you might reference the `start_time` property like so:

```javascript
"Your appointment is at {{
FORMAT_DATETIME(
session.appointment
 .start_time,
 "h:mm A z on MMMM Do, YYYY"
 )
}}
."
```

The [FORMAT\_DATETIME](../../airscript-expressions/datetime-functions/format_datetime) function converts the referenced DateTime in to a more legible format.
