Calendar Sync for Dispatcher Workspace

Published Categorized as ServiceNow Tagged , , , ,

The Field Service Management application in ServiceNow offers a dedicated workspace for dispatchers, allowing them to assign work order tasks to field agents using a drag-and-drop interface. Additionally, dispatchers can view the agents’ ServiceNow calendars to check for any existing tasks or appointments, ensuring optimal scheduling.

Maintaining up-to-date calendars is essential for the proper assignment of tasks. Therefore, it’s crucial to sync agents’ external calendars (Google, Microsoft, etc.) with ServiceNow, enabling dispatchers to directly see if an agent is occupied with other work.

Assuming that the integration for fetching calendar data from the external provider is already established, let us understand which tables need to be updated to ensure that external calendar data is accurately reflected in the dispatcher workspace.

Agent calendar

Field service and customer service agents with the ‘agent_schedule_user’ role can manually update their personal calendars within ServiceNow by navigating to ‘My Schedule’.

The agent calendar data is displayed using three interconnected tables listed below.

  • Schedule [cmn_schedule]
    • This table serves as the repository for all schedules within ServiceNow, ranging from the standard schedules like 8-5 weekday schedule to individual agents’ personal schedules.
  • Agent Personal Schedule [agent_events]
    • After a schedule is created in the ‘cmn_schedule’ table, it must be linked to the agent’s user record to be identified as a personal schedule. The ‘agent_events’ table functions as a many-to-many (m2m) database connecting the User [sys_user] and Schedule [cmn_schedule] tables.
  • Schedule Entry [cmn_schedule_span]
    • Lastly, this table stores event information such as date, time, and occurrence, with a reference to the ‘cmn_schedule’ table.

Calendar data import

The target table for calendar data will be the Schedule Entry [cmn_schedule_span] table, assuming accurate records are already present and can be referenced from the Schedule [cmn_schedule] and Agent Personal Schedule [agent_events] tables.

Once the integration with the external calendar provider is in place and ServiceNow is able to access the raw data in import sets, we can have transform mappings to process the data.

In our scenario, the data import was from Microsoft Exchange calendar and some of the values had to be pre-processed with various scripts like below.

  • ‘date_time’ pre-processing –
answer = (function transformEntry(source) {
    var dt = source.getValue('u_end_date_time');
    dt = dt.split('.')[0];
    dt = dt.replaceAll('T', ' ');
    dt = new GlideDateTime(dt);
    return dt;
})(source);
  • ‘show_as’ pre-processing –
answer = (function transformEntry(source) {
  switch (source.getValue('u_responsestatus_response')) {
        case 'accepted':
        case 'organizer':
            return 'busy';
        case 'tentativelyAccepted':
        case 'none':
            return 'tentative';
        default:
            return '';
  }
})(source);

Post sync view

Once all configurations are set and calendar data is being regularly synced, the dispatcher workspace will display agents’ personal events as long grey blocks, as shown below.

Integration options

Various integration methods can be used; in our case, we integrated with Microsoft Exchange and utilised Integration Hub spokes. The ‘Look up Calendar View Stream’ datastream action facilitated importing the data into the import sets.

Next steps

Figure out the process for handling event cancellations—specifically, if an event is deleted from the agent’s personal calendar at the source, how will this change be reflected in ServiceNow?

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses User Verification plugin to reduce spam. See how your comment data is processed.