soSIMPLE Calendar Action Script

The “soSIMPLE Calendar Actions” script is the key to customizing how soSIMPLE works for your situation.

Looking at it briefly, it might look a little daunting, but once you get the hang of it, it’s pretty simple to use.

How it works

Every time anything is done in the calendar, this script runs. Along with it, a JSON parameter is sent describing what is being done, along with any other information the script needs to do it.

One of the first steps is a “set variable” step that turns all the JSON parameters into local variable so they’re easier to use.

Another thing to note: even before this step, we have two other “set variable” steps to assign the layout name and all the field names. These steps are designed to easily point soSIMPLE to your data without redesigning the relationship graph. See our articles in Integration for details.

Back to the JSON-derived variables…

The most important variable:

$event_type

$event_type describes what the calendar is doing. The remainder of the script is broken down depending on the value of this variable.

$event_type can be:

Load

The first time the calendar is loaded.

Includes:

$mode – the name of the view such as “day”, “month”, “timeline”

$date (the specific date you’ve selected)

$max_date, $min_date (the range of dates visible on the calendar)

Like Refresh and Navigate, this section finds and displays events using these parameters. It also updates the list of available resources for the calendar

Refresh

The refresh button is clicked, or “reloadAll()” is run using Run JavaScript script step

Includes:

$mode – the name of the view such as “day”, “month”, “timeline”

$date (the specific date you’ve selected)

$max_date, $min_date (the range of dates visible on the calendar)

Like Load and Navigate, this section finds and displays events using these parameters. It also updates the list of available resources for the calendar.

Navigate

Anytime you go to a new view or a new date

Includes:

$mode – the name of the view such as “day”, “month”, “timeline”

$date (the specific date you’ve selected)

$max_date, $min_date (the range of dates visible on the calendar)

Like Load and Refresh, this section finds and displays events using these parameters. This section doesn’t update the list of available resources since you’re just navigating views.

New

When you create a new record by clicking & dragging, by double-clicking, or by clicking the big orange “+” button.

Includes $start_date, $start_time, $end_date, $end_time, and $unit. ($unit is the id or name of the resource if you selected a specific resource from the calendar).

It can also include $lat, $lng, and $location if you double-click the map.

Finally, it can also include $text, if you enabled in-line editing and create a new event in week, day or resource view.

This section

  1. opens a card window,
  2. creates a new event,
  3. then pauses.

Open

When you open an existing event by double-clicking it.

Include $id – the primary key of the event.

This is usually all you need for this step, but it also includes the other variables from “New” events.

This section

  1. opens a card window,
  2. finds the event by ID,
  3. then pauses.

Edit

You edit a record by dragging it on the calendar.

Includes $id (the primary key of the event), $start_date, $start_time, $end_date, $end_time, and $unit. ($unit is the id or name of the resource if you drag to a specific resource from the calendar). These reflect where you’re dragging the event to.

It can also include $text, if you enabled in-line editing and edit an event in week, day or resource view.

This section:

  1. opens a card window off-screen,
  2. finds the event by ID,
  3. makes the changes specified, and
  4. closes the window

State

This is only called when “getState()” is run using Run JavaScript script step.

Includes:

$mode – the name of the view such as “day”, “month”, “timeline”

$date (the specific date you’ve selected),

$max_date, $min_date (the range of dates visible on the calendar)

This step is useful for using your own calendar navigation. We’ll explain that option in a future post.

Finally, update the calendar

After all of the steps above, a JSON variable is set. This variable describes the event being edited, along with recurring events or visible events (in the case of the first three sections).

The final step in this script is to run another script (“soSIMPLE Calendar Load Events”) with these parameters to update these specific events on the calendar.

What was installed?

What was installed:

When you selected the soSIMPLE Calendar Add-On, the following things were added to your database.

Note: Removing the Add-On removes everything that was created by the Add-On, including all the tables and scripts.

  • Tables:
    • soSIMPLE Calendar Settings
      Houses all the code required for your calendar, along with some global fields for setting configurations.
    • Events
      Sample events that show on your calendar. You can use this table, or integrate your own.
    • Calendars
      Names and colors to identify different calendars. They can be turned on & off with buttons to the left of your calendar.
    • Resources
      Names and sort order for resources. These show up as rows or columns in multiple views of your calendar.
  • Scripts:
    9 scripts are created. The most important one is:
    • soSIMPLE Calendar Actions
      Runs whenever anything happens on your calendar. Actions can include: Open, edit, delete, load, navigate, refresh
  • Value Lists:
    Several value lists have to been added to help in configuring the calendar and setting event fields.