Action Objects & Methods

When working with custom actions, there are a few event-related objects that will be of use depending on whether you are building a custom action or event action.

Action Object

The action object contains the event action definition and is available in all custom and event actions, although you'll likely only use it in event actions. This object includes the type of action, the URL / javascript to be executed and other attributes. For the most part, this object should be left alone except for a few cases listed below.

action.preventAction = true;

This will prevent the event action from running the next time it is called. This is useful if you are calling the function that originally executed the event action.

action.callbacks.confirm(); and action.callbacks.cancel();

Event actions have built-in callbacks for use in asynchronous processes when “Prevent Default Action” is set to true. Useful when working with external API's where you need to wait for data or when using modal dialogs where a user is required to make a selection before continuing. Confirm will run the remainder of the action that was originally called. For example, if confirm is called in an onClick action the popover will appear. If cancel is called, the popover will not open.


Custom Actions

In Custom Actions, there are two default objects that will be of use in your code:

event - This object contains the properties of the event before it was modified.
editEvent - This object contains the properties of the event, including any changes that were made in the popover.

Example: take a look at the  emailSupport.js example here that shows how to use the event and editEvent object to send an email in a custom action.


Event Actions

In event actions, we take advantage of different objects depending on the type of action specified:

On Event Click action - runs when an event is clicked on--before the popover is opened

event - This object contains the properties of the event that is clicked on.
editEvent - This object contains the properties of the event that is clicked on. This object will contain the same contents of the event object as no data has been edited yet when clicking on an event.

On Event Create Action - runs just before a new event is rendered on the calendar

event - This object contains the properties of the event that is being created, such as the event source and dates.

Before Event Save Action - runs before any event changes are written back to the event data source

event - This object contains the properties of the event before it was edited.
editEvent - This object contains the properties of the event as it has been modified in the popover or via drag and drop. Any changes to this object will get saved to the event once the save action is called.

On Event Save Action - runs after event changes are written to the event, but before they are written to the data source, i.e. Google

editEvent - This object contains the new properties of the event including changes made either in the popover or by dragging and dropping the event.
event - This object has been set to match the editEvent object at this point, so the properties should match the editEvent object properties.
revertObject - This object contains the original state of the event properties before the changes were saved. This can be used to compare pre-save data or to revert the event data.
changesObject - This object contains only the properties that were changed as part of the save.

On Event Delete Action - runs after the delete button is clicked, but before the event is removed from the view

event - This object contains the properties of the event when the popover was opened
editEvent - This object contains the properties of the event, including any changes that were made in the popover before it was deleted.

Example: the  emailSupportOnHold.js example here shows how you can take advantage of the objects, event and revertObject


On Event Hover Action - runs when the mouse is hovered over an event on the

event - This object contains the properties of the event when the popover was opened
editEvent - This object contains the properties of the event, including any changes that were made in the popover before it was deleted.

Example: the  emailSupportOnHold.js example here shows how you can take advantage of the objects, event and revertObject


event and editEvent Objects

Here are the properties that may be found in the event and editEvent objects, their types, and the data they contain. Some properties are source-specific (Google, Basecamp, FileMaker) are object specific (event, editEvent), or are only contained in certain event actions.

allDay - boolean. True when event is marked All Day

color - string. The rgb value for the source default color

contactDisplay - string. Contact display name

contactID - array of strings. The Unique ID of the contact

contactName - array of strings

description - string. The event description contents

end - momentJS object. The event end time

eventID - string. The unique ID of the object

eventSource - string. The unique calendar source

eventURL - string. The URL of the event where the data is stored (Google/Basecamp/SalesForce)

location - string. The location of the event

projectDisplay - string. Project display name

projectID - array of strings. The Unique ID(s) of the project(s)

projectName - array of strings. The display name(s) of the project(s)

recordID - string. The record ID in FileMaker

resource - array of strings. The list of assigned resources

schedule - object. Contains source information such as name, server connection information, field mappings.

start - momentJS object. The event start time

status - array of strings. List of assigned statuses. 

tags - string. Event Tag(s)

timeEnd - string. The string value of the end time

timeStart - string. The string value of the start time

title - string. The summary of the event that is displayed in the event block on the calendar

titleEdit - string. The event title text


event and editEvent Objects in additional fields

When using additional fields in actions, you'll want to reference the field's DayBack ID, shown in the Additional Fields tab as the "ID for Calendar Actions". These look something like 23565277179927-367387787. This event action example shows how for format a field's ID inside your action:  Change the event's status.

Referencing additional fields in actions would work like this:

editEvent['your-additional-field-id']
event['your-additional-field-id']

If you want to check metadata about additional fields (like what format it is) you can reference that object like this:

editEvent.customFields['your-additional-field-id']


utilities Object

The utilities object contains useful methods in custom actions.

utilities.showModal(title, message, cancelButtonText, cancelFunction, confirmButtonText, confirmFunction); - method

Displays a popover requesting user input.

The cancel or confirm function will be performed when the user clicks the corresponding button. Use utilities.showModal('hide') to hide the modal if you're not calling one of the cancel or confirm callbacks like action.callbacks.cancel().

utilities.showMessage(content, showDelay, hideDelay, type, actionFunction);

Displays the specified message in an info bar at the bottom of the calendar window.

utilities.hideMessages();

Hides any messages that have been queued for display in the alert bar.


seedcodeCalendar Object

The seedcodeCalendar object contains details about the current calendar view.

seedcodeCalendar.get([property]);

Returns the corresponding property of the current calendar view.

Examples:

seedcodeCalendar.get(‘resources’);

Returns an array of loaded resources for the calendar.

seedcodeCalendar.get(‘statuses’);

Returns an array of loaded statuses for the calendar.

seedcodeCalendar.get('config');

Returns an object containing the global calendar configuration.

Config Properties:

.defaultTimedEventDuration - The default duration for new events

.databaseDateFormat - The default date format string for the associated source


Useful Methods

The following are useful methods available in custom and event actions.

eventChanged(editEvent, event, endShifted);

Returns the differences between an editEvent and event object. Will return false if no differences were found.

endShifted is when the end date in the editEvent object has already been set to exclusive instead of inclusive as it is in the event popover. This would be the case in the On Event Save action, however, the editEvent and event objects have already been merged so end shifted should generally be left blank or set to false.

updateEditEvent(event, editEvent);

Updates the popover data to match what is currently set in an event object.

Useful if a routine/function has updated the event object and those changes also need to reflect in a popover that is still open.

$rootScope.$broadcast('closePopovers');

Call this at the end of a custom action if you'd like to close the popover and save your changes. For example, I've created a button called "meeting attended" that checks the "attended" box, marks the status as "Closed" and then saves the event. $rootScope.$broadcast(' closePopovers'); is the last line of that custom action.

Still need help? Message Us Message Us