
DayBack allows you to manage a specific list of visible calendars for a given user but not visible for others. Using the Filter Calendar List Custom App Action, you can specify which individuals have access to view a calendar or a group of calendars, which calendars everyone should have access to, and whether there are certain users who should see all available calendars.
This method is great if you have calendars for multiple locations but want to load only those relevant to individual employees.
Example: Doctors and Receptionists
Suppose you run 3 doctors’ offices. Two doctors practice in a single office location, and one practices in two locations. Each doctor needs to view the appointments only for their own clinics, plus any corporate events that are relevant to the whole company.
Additionally, you have 3 receptionists who need to see the schedule for all three clinics, as clients may need to be booked at different offices from time to time. Lastly, all employees need to see the corporate calendar, which contains employee availability, birthdays, and corporate holidays.

Below we’ll show you how the versatility of DayBack’s custom app actions can be used to set up an organization like this.
If your business operates with multiple locations across states, each employee’s and manager’s view can be set up to aggregate events and specific resources by state, region, or another complex structure.
Add This to Your DayBack: Installing the Custom Action
- Follow the Custom App Action installation instructions
- Select “On Calendars Fetched” as your Action Type
- Set “Prevent default action” to No, and enable the action for App and for Shares
Copy and paste the full code below in the JavaScript box and edit the configuration section to reflect your specific organization’s configuration (instructions follow):
// Filter Calendar List v1.1 // Purpose: // Determine whether to show or hide specific calendars in DayBack // for everyone or individual user accounts // Action Type: On Calendars Fetched // Prevent Default Action: Yes // More info on On Calendars Fetched actions and objects here: // https://docs.dayback.com/article/140-custom-app-actions // Map the DayBack account to the calendar names that should hide or show for them. // Use 'everyone' if you don't want a specific account match // An account must be in the map object to be affected by this action // Each account should have a calendars property that includes an array of calendar names // Declare globals var options = {}; var inputs = {}; try { //----------- Configuration ------------------- // Seconds to wait to allow this action to run before reporting an error (set to 0 to deactivate) options.runTimeout = 0; // Settings are organized into Global settings which apply to everyone // and user-specific settings which add to or override global settings. inputs.calendars = { // Global Calendars Configuration: // ------------------------------- // Define list of calendars everyone should see: // // showForEveryone: [ 'Calendar 1', 'Calendar 2', 'Calendar 3' ] // // Leave list empty to show all available calendars for all users: // // showForEveryone: [] showForEveryone: [ 'Corporate Calendar' ], // Define list of calendars no one should see: // // hideForEveryone: [ 'Hidden Calendar 1', 'Hidden Calendar 2'] // // Leave list empty if you don't have calendars to hide for everyone: // If you hide calendars for everyone, these can still be shown if // specified in a user-specific calendars list: // // hideForEveryone': [] hideForEveryone: [], // Individual Calendars Configuration: // ----------------------------------- // Skip this section if you don't have user-specific settings. // // If your organization has a calendar named 'all', you will need // to redefine the viewAllCalendarName setting to a word that will // not conflict with any other calendar names in your organization. // // If the viewAllCalendarName appears in a user's calendar list // we'll show all available calendars that are not hidden for // everyone. This is helpful if you have defined a restricted // list of calendars in the showForEveryone list, but want the // ability to show all the calendars that are available for // a certain subset of your users. viewAllCalendarName: 'all', // If you don't want to define calendars by user and just // want to use globals show/hide settings, please set the // 'individualCalendars' list to null: // // individualCalendars: null // // Configure calendars by user in this format: // // individualCalendars: { // '[email protected]': [ 'Calendar 1', 'Calendar 2'], // '[email protected]': [ 'Calendar 3', 'Calendar 4'] // } // // Example scenarios: // // 1. If user is not specified, show calendars defined in // the showForEveryone setting. // 2. If user is not specified and showForEveryone is empty // show the full list of calendars that are available. // 3. If you want a user to see all calendars except hidden // ones, add the viewAllCalendarName: // [email protected]: [ 'all' ] // 4. If you want to show hidden calendars, add each hidden // calendar to the list: // [email protected]: [ 'all', 'Hidden Calendar 1' ] individualCalendars: { '[email protected]': [ 'Bellevue Calendar' ], '[email protected]': [ 'Northgate Calendar' ], '[email protected]': [ 'Northgate Calendar', 'Fremont Calendar' ], '[email protected]': [ 'all' ], '[email protected]': [ 'all' ], '[email protected]': [ 'all' ] } }; //----------- End Configuration ------------------- } catch(error) { reportError(error); } //----------- The action itself: you may not need to edit this. ------------------- // Action code goes inside this function function run() { // validate configuration if (!validateConfiguration() ) { return confirmCallback(); } // Function for recreating the calendar list and recreating based on the map // Get all calendars (schedules) var schedules = seedcodeCalendar.get('schedules'); var account = seedcodeCalendar.get('config').account; // Get calendar lists for specific DayBack account and for everyone. Then merge into one list var accountCalendarList = inputs.calendars.hasOwnProperty('individualCalendars') && inputs.calendars.individualCalendars.hasOwnProperty(account) ? inputs.calendars.individualCalendars[account] : []; var everyoneCalendarList = inputs.calendars.hasOwnProperty('showForEveryone') ? inputs.calendars['showForEveryone'] : []; var hiddenCalendarList = inputs.calendars.hasOwnProperty('hideForEveryone') ? inputs.calendars['hideForEveryone'] : []; var viewableCalendarList = accountCalendarList.concat(everyoneCalendarList); // Show all calendars if our viewable calendar list is blank. if (!viewableCalendarList || viewableCalendarList.length < 1) { viewableCalendarList[0] = accountCalendarList[0] = inputs.calendars.viewAllCalendarName; } // If we are to show all calendars for a user, remove only hideForEveryone calendars unless the calendar is listed in the user's list if (accountCalendarList && accountCalendarList.length >= 1 && accountCalendarList[0] == inputs.calendars.viewAllCalendarName) { for (var i = schedules.length - 1; i >= 0; i--) { if (viewableCalendarList.indexOf(schedules[i].name) === -1 && hiddenCalendarList.indexOf(schedules[i].name) > -1) { schedules.splice(i, 1); } } return confirmCallback(); } // Hide calendar unless we have explicit instruction to show it // Hide calendar if item isn't in our list of calendars we should show for (var i = schedules.length - 1; i >= 0; i--) { var calendarPosition = viewableCalendarList.indexOf(schedules[i].name); var hiddenPosition = hiddenCalendarList.indexOf(schedules[i].name); if (hiddenPosition > -1 && calendarPosition === -1) { schedules.splice(i, 1); } else if (calendarPosition === -1) { schedules.splice(i, 1); } } return confirmCallback(); //----------- Action-specific functions ------------------- // Configuration validation helper function function validateConfiguration() { // Make sure we have defined a list of calendars if (!inputs.calendars || typeof inputs.calendars !== 'object') { return reportError({ message: "Please configure a list of calendars"}); } // Get list of schedules and a make sure calendars are valid var schedules = seedcodeCalendar.get('schedules'); if (inputs.calendars.hasOwnProperty('showForEveryone') && inputs.calendars.showForEveryone.length > 0) { inputs.calendars.showForEveryone.forEach(calendar => { if (schedules.filter(schedule => schedule.name === calendar).length < 1) { return reportError({ message: "Show For Everyone Calendar '" + calendar + "' is not a valid calendar"}); } }); } if (inputs.calendars.hasOwnProperty('hideForEveryone') && inputs.calendars.hideForEveryone.length > 0) { inputs.calendars.hideForEveryone.forEach(calendar => { if (schedules.filter(schedule => schedule.name === calendar).length < 1) { return reportError({ message: "Hide For Everyone Calendar '" + calendar + "' is not a valid calendar"}); } }); } // Make sure viewAllCalendarName is defined if (!inputs.calendars.hasOwnProperty('viewAllCalendarName') || typeof inputs.calendars.viewAllCalendarName !== 'string' || inputs.calendars.viewAllCalendarName.length < 1) { return reportError({ message: "Please configure a View All Calendar Name"}); } else { if (schedules.filter(schedule => schedule.name === inputs.calendars.viewAllCalendarName).length >= 1) { return reportError({ message: "The View All Calendar Name '" + inputs.calendars.viewAllCalendarName + "' conflicts with a calendar name you use in your organization. Please change it to a unique word"}); } } // Check if inidividual calendars have been defined, and whether they are valid if (inputs.calendars.hasOwnProperty('individualCalendars') && Object.keys(inputs.calendars.individualCalendars).length > 0) { Object.keys(inputs.calendars.individualCalendars).forEach((emailAddress, i) => { for (var c = 0; c < inputs.calendars.individualCalendars[emailAddress].length; c++) { var userCalendars = inputs.calendars.individualCalendars[emailAddress]; if (userCalendars[c] != inputs.calendars.viewAllCalendarName) { if (schedules.filter(schedule => schedule.name === userCalendars[c]).length < 1) { return reportError({ message: "Individual calendar '" + userCalendars[c] + "' for " + emailAddress + " is not a valid calendar"}); } } } }); } // config is valid return true; } } //----------- Run function wrapper and helpers - you shouldn't need to edit below this line. ------------------- // Variables used for helper functions below var timeout; // Execute the run function as defined above try { if (!options.restrictedToAccounts || !options.restrictedToAccounts.length || (options.restrictedToAccounts && options.restrictedToAccounts.indexOf(inputs.account) > -1) ) { if (action.preventDefault && options.runTimeout) { timeoutCheck(); } run(); } else if (action.preventDefault) { confirmCallback(); } } catch(error) { reportError(error); } // Run confirm callback when preventDefault is true. Used for async actions function confirmCallback() { cancelTimeoutCheck(); if (action.callbacks.confirm) { action.callbacks.confirm(); } } // Run cancel callback when preventDefault is true. Used for async actions function cancelCallback() { cancelTimeoutCheck(); if (action.callbacks.cancel) { action.callbacks.cancel(); } } // Check if the action has run within the specified time limit when preventDefault is enabled function timeoutCheck() { timeout = setTimeout(function() { var error = { name: 'Timeout', message: 'The action was unable to execute within the allotted time and has been stopped' }; reportError(error, true); }, (options && options.runTimeout ? options.runTimeout * 1000 : 0) ); } function cancelTimeoutCheck() { if (timeout) { clearTimeout(timeout); } } // Function to report any errors that occur when running this action // Follows standard javascript error reporter format of an object with name and message properties function reportError(error) { var errorTitle = 'Error Running Custom Action'; var errorMessage = '<p>There was a problem running the action "<span style="white-space: nowrap">' + action.name + '</span>"</p><p>Error: ' + error.message + '.</p><p>This may result in unexpected behavior of the calendar.</p>'; if (action.preventDefault && timeout) { confirmCallback(); } else { cancelCallback(); } setTimeout(function() { utilities.showModal(errorTitle, errorMessage, null, null, 'OK', null, null, null, true, null, true); }, 1000); }
Configuring the Custom Action: FilterCalendarList.js
By default, DayBack will show all your calendars. This app action gives you several ways to determine who sees what:
- Show specific calendars for everyone
- Hide specific calendars for everyone
- Show specific calendars for specific users
- Show all calendars for specific users (except those hidden for all)
- Show all calendars for specific users, even those hidden for all if I explicitly list that calendar in the user’s list
For our example case, we only want to show one calendar for everyone, then we’ll show specific calendars for Doctors, and show all calendars for receptionists.
Setting up the configuration for an organization is easy. You’ll need to change the following section of the JavaScript code. Here is the configuration we created for our example organization:
inputs.calendars = { // Global Calendars Configuration: // ------------------------------- // Define list of calendars everyone should see: // // showForEveryone: [ 'Calendar 1', 'Calendar 2', 'Calendar 3' ] // // Leave list empty to show all available calendars for all users: // // showForEveryone: [] showForEveryone: [ 'Corporate Calendar' ], // Define list of calendars no one should see: // // hideForEveryone: [ 'Hidden Calendar 1', 'Hidden Calendar 2'] // // Leave list empty if you don't have calendars to hide for everyone: // If you hide calendars for everyone, these can still be shown if // specified in a user-specific calendars list: // // hideForEveryone': [] hideForEveryone: [], // Individual Calendars Configuration: // ----------------------------------- // Skip this section if you don't have user-specific settings. // // If your organization has a calendar named 'all', you will need // to redefine the viewAllCalendarName setting to a word that will // not conflict with any other calendar names in your organization. // // If the viewAllCalendarName appears in a user's calendar list // we'll show all available calendars that are not hidden for // everyone. This is helpful if you have defined a restricted // list of calendars in the showForEveryone list, but want the // ability to show all the calendars that are available for // a certain subset of your users. viewAllCalendarName: 'all', // If you don't want to define calendars by user and just // want to use globals show/hide settings, please set the // 'individualCalendars' list to null: // // individualCalendars: null // // Configure calendars by user in this format: // // individualCalendars: { // '[email protected]': [ 'Calendar 1', 'Calendar 2'], // '[email protected]': [ 'Calendar 3', 'Calendar 4'] // } // // Example scenarios: // // 1. If user is not specified, show calendars defined in // the showForEveryone setting. // 2. If user is not specified and showForEveryone is empty // show the full list of calendars that are available. // 3. If you want a user to see all calendars except hidden // ones, add the viewAllCalendarName: // [email protected]: [ 'all' ] // 4. If you want to show hidden calendars, add each hidden // calendar to the list: // [email protected]: [ 'all', 'Hidden Calendar 1' ] individualCalendars: { '[email protected]': [ 'Bellevue Calendar' ], '[email protected]': [ 'Northgate Calendar' ], '[email protected]': [ 'Northgate Calendar', 'Fremont Calendar' ], '[email protected]': [ 'all' ], '[email protected]': [ 'all' ], '[email protected]': [ 'all' ] } };
Note how each receptionist has been granted access to view ‘all’ calendars in the customization above. The doctors have access only to the calendars of the locations at which they work.
See it in Action
Here’s an example of Dr. Ash’s view when he opens up DayBack. He sees when he and Dr. Max are working together at the Northgate location. At 12:00pm, Dr. Ash can see that he must be at the Fremont location to staff the walk-in clinic that day. He can also see it’s Dr. Jane’s birthday today on the corporate calendar.

Here is the receptionist’s view of the office staffing for the day:

Pretty cool. If the receptionist doesn’t need to view appointments for other clinics, they can toggle those off and on. And they can easily switch on another clinic to see availability at that location.
Are you ready to try it out for your organization? Please get in touch if you have questions.
Leave a Reply