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 or JavaScript to be executed, and other attributes. Generally, this object should be left alone except for a few specific cases listed below.

Preventing an Action:

  • action.preventAction = true;

This prevents 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.

Using Callbacks:

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

Event actions have built-in callbacks for use in asynchronous processes when "Prevent Default Action" is set to true. These are useful when working with external APIs where you need to wait for data or when using modal dialogs where a user is required to make a selection before continuing.

  • confirm() : Runs the remainder of the action that was originally called. For example, if confirm() is called in an On Event Click action, the popover will appear.
  • cancel() : Prevents the popover from opening.

Params Object

The params  object contains a data property that contains information about the event that invoked the action. All actions that trigger when a user interacts with the calendar will include a params object. These actions are:

  • After Events Rendered
    • fromFilterChange  : Was this initiated from a filter being toggled on or off.
    • fromRefresh : Was this triggered by the calendar being refreshed.
    • fromScheduleChange : Was this triggered by a calendar being toggled on or off.
    • fromViewStateChange : Was this triggered by the calendar view changing (view changed, date changed, window resized, sidebar closed/opened).
  • After Source Selection
    • isLast : Is this the last calendar source in a folder that is set to be applied. When selecting a folder, this trigger is fired once for each source.
    • item : Details on the calendar source that was toggled.
  • After Filter Selection
    • filterType : The filter that was changed (statuses or resources).
    • isLast : Is this the last filter in a folder that is set to be applied. When selecting a folder, this trigger is fired once for each filter inside that folder.
    • item : Details on the filter that was toggled.
  • On Field Change
    • field : The name of the popover field that was changed.
    • value : The resulting value that was changed.
    • selected : Was the value toggled on or off.
    • objectName : Salesforce Only - the object name of the related record.
  • After Draft Mode Toggle
    • isDraftMode : Is draft mode enabled or disabled - Boolean
    • type : The action that triggered the toggle - String: enable, discard, publish, save
    • draftId : The unique Id of the current draft - String

dbk Object

The dbk object offers several methods specifically designed for use in calendar, custom, and event actions. These methods are available in their respective scopes.

Functions for Tooltips, Modals, Popovers and Toggling of Filters

dbk.tooltip(content, options)

  • Invokes the tooltip action as documented here.

dbk.showMessage(content, showDelay, hideDelay, type, actionFunction)

  • Displays a specified message in an info bar at the bottom of the calendar window. This function is equivalent to utilities.showMessage() described below.

dbk.refreshEditPopover(editEvent)

  • Updates the popover with the data in the editEvent object. Useful for reflecting changes made to fields in your event action. This also updates the color swatch on the event if the primary status value has changed.
  • Example:
// Change the primary status value
editEvent.status[0] = 'completed';
dbk.refreshEditPopover(editEvent);

dbk.mutateFilterField(filterItem)

  • Mutates a Status or Resource filter object correctly, converting necessary data types and applying required formatting. Useful when modifying resource or status details.
  • The Resource and Status filter arrays can be retrieved using the seedcodeCalendar object below.
  • Example:
var resources = seedcodeCalendar.get('resources');
var newResource = {
   name: 'New Employee',
   description: 'Lead Tech',
}

// Mutate and format the new resource data
dbk.mutateFilterField(newResource);

// Add the new resource data to the resource list
resources.push(newResource);

// Initialze the resource list so the sidebar knows that data has updated
seedcodeCalendar.init('resources', resources);

// Reset the resources so calendar views are updated to reflect resource changes
dbk.resetResources();

dbk.filterFieldSort(filterArray)

  • Sorts the Status or Resource filters correctly, maintaining their folder structure. Useful for resorting the filter array after manipulation with an action.
  • The Resource and Status filter arrays can be retrieved using the seedcodeCalendar object below.

dbk.resetResources()

  • Resets the columns or rows in the Resource view. This should be invoked if the resource array has been manipulated by an action to reflect changes in the resource views.
  • The calendar array can be retrieved from the seedcodeCalendar object using seedcodeCalendar.get('schedules')

dbk.toggleCalendar(calendar)

  • Selects or deselects a calendar on the calendar tab depending on its current state.
  • The Calendars array can be retrieved using the seedcodeCalendar object below.

dbk.toggleMultiSelect(event, shiftKey, targetElement, view, forceDeselect)

  • Programmatically selects or deselects an event as part of the multi-select process. For an example of this in action, refer to the "Select All Events for Multi-Select" example in  Custom App Actions.
  • Parameters:
    • event : The event object of the item being selected or deselected.
    • shiftKey : Boolean indicating if the shift key is pressed.
    • targetElement : The DOM element on the calendar that corresponds to the event object.
    • view : The current DayBack view, typically seedcodeCalendar.get('view') .
    • forceDeselect : Boolean to specify if all events should be deselected. When three, the first 3 parameters should be null .

Functions for Adding, Editing, Displaying, and Deleting Events:

dbk.addEvent(event)

  • Renders an event on the calendar. If a Customo Action creates an ad-hoc event that's not in a data source, this function must be used to add it to the calendar view. This function should be used for single events for performance reasons. Usedbk.addEvents() for adding multiple events.

dbk.addEvents(eventArray)

  • Similar to dbk.addEvent() , but accepts an array of events. This function adds multiple events to the calendar in a single operation.

dbk.updateEvent(event, changesObject, revertFunction, callback, options)

  • Updates an event with an app action.
  • Parameters:
    • event : An event object containing original event properties.
    • changesObject : An object containing the event properties names and values that need to be changes.
    • revertFunc : A function called when an update returns an error, resulting in a reversion.
    • callback : A function called when the update is complete or has failed.
      • If config.passthroughEditErrors is set to true, any error that occurs during the update process will be passed to the callback function, rather than displayed to the user.
    • options : An optional object containing the following properties:
      • endShifted : Boolean indicating whether end times have already been adjusted for all day events.
      • isCustomAction : Boolean indicating whether previously stored revertFunction() should be reset to null . This DayBack to process reversions itself.
      • isUndo : Boolean indicating if the update is an undo event, and should not be put in the undo memory stack.

dbk.createEvent(paramObject)

  • Creates events on a specific calendar source and adds them to the calendar display.
  • Unlike dbk.addEvent() this function adds the event to the calendar display, while also creating it in whatever data source is specified. Useful for bypassing all user interaction to creating and saving events.
  • Parameters Object Values:
    • event
      • Must contain at least a title property and a start property formatted as a moment object .
      • Optionally, can be an array of objects if creating multiple events.
      • Can include any valid DayBack field properties.
      • If calling this function from an event action, simply pass the event object itself. Specifying this property as event: event will clone the original event.
    • calendarID
      • The internal ID of the calendar to which you want to add this event.
      • Required only if calendarName is not set.
    • calendarName
      • The name of the calendar to add the event to.
      • Required only if the calendarID is not set.
    • preventWarnings
      • Set to true to avoid warnings about data formatting or payload size when creating many events.
      • A warning dialog will appear if adding more than 200 events at once, as too many events could trigger rate limiting with the provider.
    • renderEvent
      • A boolean that, when set to true , renders the event on the calendar.
      • Useful if you want to add the event to the calendar source and give immediate feedback by showing the created event on the calendar.
    • callback
      • A function that runs once the creation process is completed.
      • The result of the callback is an object containing the following properties:
        • event : The event data that was created or failed to create.
        • isShown : Boolean indicating whether the event is shown on the calendar display. Reasons for not showing could include the calendar not being selected or a filter being applied that prevents the event from displaying.
        • error : An error object that contains a message property if there was an error. For example: error: {message: 'The event could not be created'} .
        • Example:
let newEvent = { title: 'Meeting', start: moment('2021-12-15') };
let params = {
    event: newEvent,
    calendarName: 'Team Calendar',
    renderEvent: true,
    callback: function(result) { }
}
dbk.createEvent(params);

dbk.deleteEvent(paramObject)

  • Deletes events from the calendar view and the calendar source.
  • Parameters:
    • event
      • A native DayBack event object.
      • An array of currently-viewed even objects can be obtained by calling seedcodeCalendar.get('element').fullCalendar('clientEvents') or seedcodeCalendar.get('element').fullCalendar('unscheduledClientEvents') .
      • If calling this function from an Event Action, directly pass the event object. In that case, specifying this property as event: event will delete the original event.
    • editEvent
      • Optional if the event property is not specified.
      • Available in the context of an Event Action when the popover is open.
    • callback
      • A function that runs once the deletion process is completed.
      • The result of the callback is null unless there was an error.
      • If there is an error, it returns an object containing the following properties:
        • error: An error object that contains a message property if there was an error. For example: error: {message: 'The event could not be deleted'}

dbk.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 be reflected in a popover that is still open.
  • Note: If you are trying to update the popover from an async operation like a callback from an API request, you need to trigger a digest cycle. To do this, wrap your update in a $timeout as shown below.

dbk.eventChanged(editEvent, event, endShifted)

  • Returns the differences between an editEvent and event object. It will return false if no differences are found.
  • Parameters:
    • editEvent : The new event object (after changes)
    • event : The original event object (before changes)
    • endShifted : Indicates if the end date in the editEvent object has already been set to exclusive instead of inclusive, as it is in the event popover. This is generally the case in the On Event Save action. The editEvent and event objects have already been merged, so endShifted should usually be left blank or set to false.

Functions for Date and Time Conversion, Custom Field Retrieval, and Event Sorting

dbk.localTimeToTimezoneTime(date, isAllDay)

  • Converts a local date/time to a date/time based on a timezone set in config.clientTimezone  (such as the timezone chosen in this timezone selector for DaBack).
  • Applies the appropriate offset without changing the timezone of the date object.
  • Parameters:
    • date : Must be a valid moment object.
    • isAllDay : A boolean indicating whether times should be ignored.

dbk.timezoneTimeToLocalTime(date, isAllDay)

  • Converts a date/time from a specific timezone set in config.clientTimezone back to the local time set in the operating system.
  • Removes the previously applied offset without changing the timezone of the date object.
  • Parameters:
    • date : Must be a valid moment object.
    • isAllDay : A boolean indicating whether times should be ignored.

dbk.getCustomFieldIdByName(storeInFieldName, schedule)

  • Retrieves the numerical ID for a custom field based on the "Store in Field Name" value defined in your calendar's Custom Field mapping.
  • Function requires you pass the schedule object from the event or editEvent objects where your field mappings are defined.
  • See usage examples.
  • Parameters:
    • storeInFieldName : A string containing the name of the custom field.
    • schedule : The schedule object from the event or editEvent objects.

dbk.setEventSortPriority(event, sortValue)

  • Sets a sort priority for an event.
  • Primarily meant to be used in the Before Event Render action, though other trigger types can be useful.
  • Learn more about sorting events here: sorting Events.
  • Parameters:
    • event : The event object where the sort priority will be set.
    • sortValue : A string or number that determines the sort order of events.
  • Example:
// 
// Sort events based on values from a mapped field
//

var sortValue = "[[Summary]]" // This should be your field name that is used in field mapping

dbk.setEventSortPriority(event, sortValue);
		
//
// Sort events based on a specified sort order of statuses
//

var sortOrder = [ 'Cancelled', 'OutOfOffice','Busy' ];
var fieldValue = event.status[0];
var sortPriority;

if (fieldValue) {
  sortPriority = sortOrder.indexOf(fieldValue);
  if (sortPriority === -1) {
    sortPriority = null;
  }
}

dbk.setEventSortPriority(event, sortPriority);

dbk.setEventSortOverride(event, sortValue)

  • Overrides the natural sort order of events.
  • Primarily used in the Before Event Render action but may have other uses.
  • Unlike dbk.setEventSortPriority() , this function changes the order of events regardless of their duration and start time.
  • Parameters:
    • event : The event object where the sort priority will be set.
    • sortValue : A string or number that determines the sort order of events.

Functions for Kiosk Mode, Bookmark Retrieval, and Translations

dbk.startKioskMode(refreshInterval, preventDateChange)

  • Enables kiosk mode without needing to pass the kiosk URL parameter, allowing it to be enabled in Salesforce.
  • Parameters:
    • refreshInterval : The number of minutes to wait between refreshing the calendar events. Minimum value is 1 .
    • preventDateChange : A boolean with a default value of false . Setting this to true prevents the date from changing to today when the calendar is refreshed.

dbk.getBookmarkList(callback)

  • Retrieves an object of all bookmarks the currently signed-in user has access to.
  • Useful for programmatically loading a bookmark based on criteria like matching name.
  • The callback will contain a result parameter with a result object or null if there are no bookmarks.
  • Example:
dbk.getBookmarkList(function(result) {
    if (result) {
        // Get a bookmark with the name "My Bookmark"
        var bookmark = Object.values(result).find(function(b) {
            return b.name === 'My Bookmark';
        });

        // Load the bookmark
        if (bookmark && bookmark.id){
            seedcodeCalendar.init('bookmarkID', bookmark.id);
        }
    }
});

dbk.getTranslations(termsToTranslate)

  • Takes an array of terms to translate and returns an array of those terms translated into the current language.
  • Example:
const translations = dbk.getTranslations(['Saturday', 'Sunday']);
utilities.showModal(
   `The Day Is ${translations['Saturday']}`, 
   `The next day is going to be ${translations['Sunday']}`, 
   'Close'
);

dbk.getLanguage()

const translationDefinitions = {
    en: { first: 'first' },
    es: { first: 'primero' }
};
let language = dbk.getLanguage();
if (!translationDefinitions[language]) {
    language = 'en';
}
const translations = translationDefinitions[language];
console.log(`This is translated ${translations['first']}`);

dbk.updateAltView(options)

  • Modifies the state of the right hand alt-view sidebar that contains unscheduled events and the map if it's enabled. Used primarily to show or hide the right hand sidebar.
  • Parameters:
    • options : An object that contains the options to set. The available properties are show (boolean) and type (string). The possible types are "map" and "unscheduled".
  • Example:
dbk.updateAltView({show: true, type: 'unscheduled'});

Functions for Creating Custom Triggers by Intercepting DOM Changes

dbk.observe({name:..., watch:..., until:..., then:...})


Button Actions

In Button Actions, two default objects will be useful in your code:

  • event : Contains the properties of the event before it was modified.
  • editEvent : Contains the properties of the event, including any changes made in the popover.

Example: Check out the emailSupport.js example to see how to use the event and editEvent objects to send an email in a custom action.


Event Actions

Event actions utilize different objects depending on the type of action specified:

On Event Click:

  • Runs when an event is clicked before the popover is opened.
  • Available Objects:
    • event : Contains the properties of the clicked event.
    • editEvent : Initially contains the same properties as the event object. Modify properties to update the event/popover values.

On Event Create:

  • Runs before any event changes are written back to the event data source.
  • While properties of the editEvent object can be modified here, Before Event Save actions are the best trigger type to use for validation before continuing to save the updated event.
  • Objects and Properties:
    • event : Contains the properties of the event before it was edited.
    • editEvent : Contains the properties of the event as modified in the popover or via drag and drop. Modify properties here to update values before saving.
    • event.beforeDrop : Object is present when an event is edited via drag and drop. Contains values before the drag began. Useful for detecting and rolling back unwelcome changes.

Before Event Save:

  • Run before changes made to an event are saved. This is the best trigger to use when you need to perform validation, correct data-entry mistakes, or modify the event in some way before it is saved.
  • This is the best place to modify properties of the editEvent object, and is a useful trigger for validation before continuing to save the updated event to the data source.
  • Objects and Properties:
    • event : The properties of the event object reflect the values before an event is updated with the contents of the editEvent object.
    • editEvent : Contains the new properties of the event, including changes made in the popover or by dragging and dropping the event.
    • options : Contains a single property, isUndo , which identifies if this action is the result of an undo operation. Undo actions are triggered by clicking the Undo part of the save confirmation message that appears at the bottom of the calendar when an event is saved or deleted.
    • event.beforeDrop : Present when an event is edited via drag and drop. Contains the values of the properties before the drag began. Useful for detecting if an event is being edited via drag and drop and for potentially rolling back values.

On Event Save:

  • Runs after event changes are written to the event but before they are saved to the data source (e.g., Google).
  • Objects and Properties:
    • event : Matches the properties of the editEvent object. Properties are identical.
    • editEvent : Contains the new properties of the event, including changes made in the popover or by dragging and dropping the event.
      • Note: The editEvent object is only used to reference the entire state of the event popover. Editing properties of this object has no effect on the save process. To make changes, see changesObject below.
    • options : Contains a single property, isUndo , which identifies if this action is the result of an undo operation. Undo actions are triggered by clicking the Undo part of the save confirmation message that appears at the bottom of the calendar when an event is saved or deleted.
    • event.beforeDrop : Present when an event is edited via drag and drop. Contains the values of the properties before the drag began. Useful for detecting if an event is being edited via drag and drop and for potentially rolling back values.
    • revertObject : Contains the original state of the event properties before the changes were saved. This can be used to compare pre-save data or revert the event data.
    • changesObject :  Object contains only the properties that were changed as part of the save process
      • Note: You can modify field properties before they are saved back to the datasource by editing the changesObject .

Example 1:

  • You can also delete a property in the changesObject if you don't want it to be saved. To prevent updating the description if the status is (or includes) "Pending":
if (event.status.includes('Pending')) {
    delete changesObject.description;
}

Example 2:

  • You can add properties to the changesObject if there are additional fields you'd like to set that are not in your calendar's field mapping. This can be useful for Salesforce setups.
  • For example, if you have a field called Done__c and it should be set to true only if the status is "Completed" and description contains "Signed Off," you could accomplish that in an On Event Save action like this:
if (event.status === ['Completed'] && event.description.includes('Signed Off')){
    changesObject.Done__c = true;
} 

On Event Delete:

  • Runs after the delete button is clicked but before the event is removed from the view.
  • Available Objects:
    • event : Contains the properties of the event when the popover was opened.
    • editEvent : Contains the properties of the event, including any changes made in the popover before deletion.

On Event Hover:

  • Runs when the mouse hovers over an event.
  • Available Objects:
    • event : Contains the properties of the event.

Before Events Fetched:

  • Runs just before the events are fetched for a particular calendar source.
  • Available Objects:
    • There are no event-related objects available in this context.

Before Event Rendered:

  • Runs just before the event is rendered on the calendar.
  • Available Objects:
    • event : Contains the properties of the event. Modify properties to change values on the calendar and popover.
      • Note: Changes made to this object aren't saved to the data source, unless a user opens and saves an event.
  • For example, to show all events for this calendar as assigned to the "Truck 1" resource, use:
    • event.resource = ["Truck 1"];

On Field Change:

  • Runs when a field is changed in the event popover.
  • Available Objects:
    • event : Contains the properties of the event when the popover was opened.
    • editEvent : Contains the properties of the event, including changes made in the popover. Modify properties to update fields in the popover.
    • params : Contains information on the change that was made. See the Params Object for more details.

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), object-specific (event , editEvent ), or only contained in certain event actions.

  • attendees : A list of attendees in the format expected by Google and O365 APIs.
  • allDay : Boolean. True when the event is marked as All Day.
  • className : Array or string. If you'd like to add a specific class name for the event on the calendar, you can modify this value. Use the following syntax to handle various formats:
let myClass = 'my-class-name';
if (Array.isArray(editEvent.className)) {
   editEvent.className.push(myClass);
} else {
   editEvent.className = (editEvent.className || '') + ' ' + myClass;
}
  • color : String. The RGB value for the source default color.
  • contactDisplay : String. Contact display name.
  • contactID : Array of strings. The unique ID(s) of the contact(s).
  • contactName : Array of strings. The display name(s) of the contact(s).
  • description : String. The event description contents.
  • end : Moment.js object. The event end time.
  • eventID : String. The unique ID of the event.
  • 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 : Moment.js 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.
  • unscheduled : Boolean. True adds the event to the unscheduled list and removes it from the calendar.

Access Custom Fields in event and editEvent Objects

When using JavaScript to access your custom fields inside Event Actions and Button Actions, you need to reference the custom field's DayBack ID. This ID is shown in the Additional Fields tab as the "ID for Calendar Actions" inside the event object.

For example, in the screenshot below, you'll see the ID for the field named truckNumber looks like 1721951289977-5615655122 .

To edit an event's truckNumber field, use this ID as the name of the property in either the event or editEvent object.

// Set truckNumber using the field's ID
event['1721951289977-5615655122'] = "Truck Number 1";

To check metadata about additional fields (such as their format), you can reference the object like this:

event.customFields['1721951289977-5615655122']

To make your app action code more readable, it's often preferable to refer to your numerical Field IDs by a human-readable name inside your JavaScript. Here's an example that retrieves the numerical ID, using the Custom Field name 'truckNumber' defined inside the current event's schedule  object. This code uses the dbk.getCustomFieldIdByName()  helper function to introspect this object.

// Retrieve numerical ID for truckNumber
const fieldId = dbk.getCustomFieldIdByName('truckNumber', event.schedule);
const truckNumber = event[fieldId];

// Set truckNumber using the field's ID
event[truckNumber] = "Truck Number 1";

utilities Object

The utilities object contains useful methods for custom actions.

Methods:

  • utilities.showModal(title, message, cancelButtonText, cancelFunction, confirmButtonText, confirmFunction)
    • 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 a specified message in an info bar at the bottom of the calendar window.
    • Parameters:
      • content : The HTML or string value to display in the message bar.
      • showDelay : Number value in milliseconds before showing the message.
      • hideDelay : Number value in milliseconds before hiding the message.
      • type : Either null for a normal message or 'error' for an error message with a red background.
      • actionFunction : JavaScript function to run if the message bar is clicked. Can be null .
  • utilities.hideMessages([type])
    • Hides messages or modals.
    • Parameters:
      • 'message' (default): Hides any queued messages in the alert bar.
      • 'modal' : Hides any modal window displayed on the calendar.
  • utilities.generateTextColor(colorCode)
    • Returns a color code representing the best text color for readability against the given background color.
    • Parameters:
      • colorCode : The background color of your event.
  • utilities.getDBKPlatform()
    • Returns a string representing the platform of the user connected to DayBack.
    • Possible values:
      • 'dbkfmwd' : FileMaker WebDirect
      • 'dbkfmjs' : FileMaker Client
      • 'dbksf' : Salesforce
      • 'dbko' : Browser
  • utilities.popover(config, template)
    • Creates a custom floating popover or modal.
    • Examples: The rich text editor is a great example of using this function in a custom action. You'll also find this in our dialog-with-buttons example.
    • Parameters:
      • config : An object containing the popover configuration with the following properties:
        • container : The DOM element to add the popover to.
        • id : The unique id for the container element.
        • type : The type of popover ('modal' or 'popover' ).
        • class : A string of the CSS class name to apply to the popover.
        • width : Number defining the width of the popover.
        • height : Number defining the height of the popover.
        • positionX : Number defining the vertical position relative to the container (popover type only).
        • positionY : Number defining the horizontal position relative to the container (popover type only).
        • staticHeight : Boolean to auto-adjust the height or not.
        • direction : Direction for the popover to appear ('auto' ).
        • onShow : Function to run at the beginning of showing the popover.
        • onShown : Function to run once the popover is fully shown.
        • onHide : Function to run at the beginning of hiding/closing the popover.
        • onHidden : Function to run once the popover is fully hidden/closed.
        • show : Boolean indicating whether to show the popover when created (popover type only).
        • destroy : Boolean indicating whether to destroy (remove from the DOM) the popover when closed (popover type only).
        • User-defined properties: Functions to run on "ng-click" actions inside your template HTML.
      • template : An HTML template defining the content of the popover.
        • Buttons can have an ng-click property pointing to popover.config.yourCustomFunction(); where yourCustomFunction is a user-defined property in the config object.

environment Object

The environment object contains useful properties for custom actions.

  • environment.isMobileDevice : A property to determine if the user is on a mobile device, including tablets/iPads.
  • environment.isPhone : A property to determine if the user is on a phone (tablets/iPads will return false).
  • Example usage:
if (environment.isMobileDevice) {
  // Your code here
}

if (environment.isPhone) {
   // Your code here
}

seedcodeCalendar Object

The seedcodeCalendar object contains details about the current calendar view.

Methods

  • seedcodeCalendar.get(property)
    • Returns the corresponding property of the current calendar state.

Usage 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('schedules')
    • Returns an array of all the calendar sources and their enabled status.
  • seedcodeCalendar.get('view')
    • Returns an array of properties for the current view. For example, view.name could be basicHorizon .
  • seedcodeCalendar.get('date')
    • Returns an array of properties for the date in focus. These are the moment.js properties of the date.
  • seedcodeCalendar.get('element')
    • Returns an array of the DOM properties.
    • For example, this would return an array of all the events in the DOM:
      • seedcodeCalendar.get('element').fullCalendar('clientEvents')
      • seedcodeCalendar.get('element').fullCalendar('unscheduledClientEvents')
  • seedcodeCalendar.get('textFilters')
    • Returns the string content of the current text filter.
  • seedcodeCalendar.get('sidebar')
    • Returns an array reflecting the current state of the sidebar, including the currently selected tab.
    • This is not for looking at which filters are applied; use get('statuses') or get('resources') for that.
  • seedcodeCalendar.get('multiSelect')
    • Returns the multiSelect object, which contains a collection of objects with details on selected events.
    • If you just want the IDs of the events currently selected in multi-select, use:
      • Object.values(seedcodeCalendar.get('multiSelect')).map(a => a.event.eventID)
  • seedcodeCalendar.get('analytics')
      • Returns the analytics object, which consists of a summary data structure identifying the field being analyzed (analytics.breakdownSummary ) and an array of items representing the data series (analytics.breakdownItems ). The latter contains item totals for the values of the analyzed field.
      • Each value in the data series includes a full name description, a short description, the total events found that match that value, and the colors used to represent this value in the analytics breakdown summary. The analytics data structure can be used to create other chart types, such as a pie chart or bar graph, using the Chartist.js charting module, which is preloaded and available for your use.
  • seedcodeCalendar.get('config')
    • Returns an object containing the global calendar configuration.
    • Config Properties:
      • Properties denoted with a * Can be modified in a Before Event Rendered action to configure the calendar.
      • .account : String - The account (email) of the logged-in user.
      • .accountName : String - The full name of the logged-in user.
      • .admin : Boolean - Indicates if the logged-in user is an admin.
      • .databaseDateFormat : String - The default date format for the associated source.
      • .defaultTimedEventDuration : String - The default duration for new events.
      • .firstName : String - First name of the logged-in user.
      • .hideMenuItems : String - A list of hidden menu items.*
      • .homeUrl : String - The URL that the Home button links to.*
      • .isMobileDevice : Boolean - Indicates if the user is on a mobile device.
      • .isShare : Boolean - Indicates if the calendar being viewed is a share.
      • .lastName : String - Last name of the logged-in user.
      • .lockSidebar : Boolean - Indicates if the sidebar is locked for this session.*
      • .passthroughEditErrors : Boolean - When set to true, messages from editing events with dbk.updateEvent() will be passed back to the callback function, rather than displayed in a modal to the user.
      • .suppressEditEventMessages : Boolean - When set to true, no messages from editing events are presented to the user. Set to false to re-enable these messages.
    • Config Methods
      • .eventShown(event, constrainToView, timedView)
        • Returns true if the event would be shown on the calendar with the current filter set. Available parameters include:
        • event : The event to check.
        • constrainToView : If true, only events within the visible date range are included.
        • timedView : Set to true if the view is a timed/schedule view. You can detect the current view with seedcodeCalendar.get('view').name .

Filter Objects

Resource and status filters are stored as arrays of objects within the seedcodeCalendar object. You can modify these objects or build your own list of filters when the calendar starts up using an On Statuses Fetched or On Resources Fetched app action (See custom app actions)

Filter Object Properties

  • name (required) - string: The name of the filter.
  • id (optional/autogenerated) - string: The ID of the filter.
  • sort (optional) - number: The desired position of the filter.
  • shortName (optional) - string: Resources only. The short name of the filter.
  • class (optional) - string: Resources only. The CSS class assigned to the filter.
  • description (optional) - string: Resources only. The description of the filter. Can contain HTML.
  • color (optional) - string: Statuses only. The RGB or RGBA value for the filter color.
  • folderID (optional) - string: The folder ID that the filter belongs to.
  • folderName (optional) - string: The folder name that the filter belongs to.
  • isFolder (optional) - boolean: Indicates if this is a folder. Defaults to false.
  • nameSafe (read only) - string: The filter name without special characters.
  • display (read only) - string: The display value of the filter name.
  • status (optional) - object: The state of the filter.

Status Object Properties

  • selected (optional) - boolean: Indicates if the filter is selected (toggled on). Defaults to false.
  • folderExpanded (optional) - boolean: Indicates if the folder is expanded. Defaults to false.

Tag Object Properties

  • name (required) - string: The name of the tag.
  • class (optional/autogenerated) - string: The CSS class assigned to the tag.

Example

Here's an example of how you might use these properties in a filter object:

let resourceFilter = {
    name: "Conference Room",
    id: "12345",
    sort: 1,
    shortName: "Conf Room",
    class: "conf-room",
    description: "This is the main conference room.",
    folderID: "67890",
    folderName: "Rooms",
    isFolder: false,
    status: {
        selected: true,
        folderExpanded: false
    },
    tags: [
        {
            name: "Large",
            class: "tag-large"
        },
        {
            name: "Projector",
            class: "tag-projector"
        }
    ]
};

let statusFilter = {
    name: "Pending",
    id: "54321",
    sort: 2,
    color: "rgba(255,0,0,0.5)",
    folderID: "98765",
    folderName: "Statuses",
    isFolder: false,
    status: {
        selected: false,
        folderExpanded: true
    }
};

// Adding filters to seedcodeCalendar
seedcodeCalendar.get('resources').push(resourceFilter);
seedcodeCalendar.get('statuses').push(statusFilter);

This example creates a resource filter and a status filter with various properties, including name, ID, sort order, class, description, and status, and then adds them to the seedcodeCalendar object.


Useful Methods

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

$timeout()

  • A standard timeout method that can be used to update data in view when that data is updated from an asynchronous operation. Setting data inside a $timeout will trigger a digest cycle and update the view.
$timeout(function() {
	// Set the editEvent data here
	//
	//
}, 0);

seedcodeCalendar.init('closePopovers', true)

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

seedcodeCalendar.get('element').fullCalendar('refetchEvents')

  • This will refresh the whole calendar, retrieving all your events again.


Finding a User's Profile in Salesforce

Since only admins can query for profile names in Salesforce, it's best to use the profile ID instead.

To get the current user’s profile ID, use the variable:context.user.profileId

For example, if you want to determine if a user is a Community User by their profile ID, you can use the following code:

const context = fbk.context();
let isExperience = false;
if (context.user.profileId === '') {
    isExperience = true;
}

After determining the user's profile type, you can apply specific styling for these users, similar to what is described in the article on Customizing DayBack's Look and Feel for Different Users