• Skip to main content
  • Skip to primary sidebar

DayBack

The Calendar You've Been Waiting For

  • Scheduling Platform
    • Salesforce Calendar
    • Overview
    • Field Service Scheduling
    • Call Center and Med Spa Scheduling
    • Calendar Sharing in Salesforce
    • Online Booking for Salesforce
    • FileMaker Calendar
    • Supabase Calendar
    • Epic and EHR Calendars
    • Other Integrations
      • For Google Calendar
      • For Google Sheets
      • For Microsoft 365
      • For Basecamp
    • Custom Salesforce Development
  • Extensions
  • Pricing
  • Blog
  • Support
    • Contact Us
    • Support Options
    • Documentation
    • Documentation for DayBack Classic (older)
    • Custom Salesforce Development
    • Implementation Packages
    • Latest Updates
    • Server Status
  • About
    • About Us / Mission
    • Team & Community
    • Careers
    • Timelines
      • Overview
      • History of the polio vaccine
      • Women’s Suffrage
      • Science Fiction
      • Your Vote in Context: the 2020 US Elections
      • History of Claris FileMaker
  • +1 (855) 733-3263
  • Sign In

Jul 10 2021

Extending TaskRay with DayBack: Adding Times and Timezones

We recently had the opportunity to work with a customer, 2Win Global, who has been a long-time fan of TaskRay. 2Win trains the largest and most successful technology companies globally to improve their sales demos and presentations resulting in improved win-rates and revenue. They’d been hosting all-day training workshops, but now that they were doing lots of coaching over Zoom, they needed to schedule hourly and needed start times for their sessions which were increasingly held in different timezones from the person scheduling them.

We had a unique problem; we implemented TaskRay before transitioning to 100% virtual and discovered that tasks with a start date and end date were no longer enough. We needed start and end times. Enter DayBack; with a few scripts, we could integrate TaskRay into DayBack for complete visibility by the hour. The other huge feature is the ability to see when resources are available, thus improving our team utilization and profitability. The team at DayBack is fantastic, and I can see why they have a perfect five-star rating. It’s a five-star team!” ย 

Ron Kendig, VP 2Win! Global – Ron’s โญ๏ธโญ๏ธโญ๏ธโญ๏ธโญ๏ธ review of DayBack on AppExchange

Many of their tasks needed to be scheduled for specific times of the day. The customer wanted to take advantage of DayBackโ€™s resource views to track the task ownerโ€™s availability and avoid double booking. With a little bit of customization, we added time fields that work seamlessly with TaskRay’s dates.

TaskRay in Salesforce
TaskRay is a popular and powerful task management app for Salesforce

TaskRay Uses Dates, not Date/Times

TaskRay has two primary date fields used for scheduling. The Start Date field and the Estimated End Date field. DayBack supports this configuration without any customization and works especially well in the Resource List view, where all the tasks assigned to a person are listed without times in their column. For organizations who arenโ€™t using tasks scheduled for specific times, this can be a great view for seeing which tasks are assigned to which people.

TaskRay Resource Scheduling
Tasks from TaskRay in DayBackโ€™s Resource List View

Resource Scheduling with Date/Times

Our customer wanted a similar view and wanted to specify times for some tasks while leaving some tasks with just dates. DayBackโ€™s Resource Schedule view is perfect for this as it keeps the tasks without times in the All-Day section at the top of the columns and renders tasks with specific times below.

TaskRay all-day tasks
Tasks without times in DayBackโ€™s Resource Schedule View

Adding Times and Timezones to TaskRay

Our customer wanted to add times to tasks so that they would display in the appropriate cell in DayBack; they also wanted to keep all of the date functionality that TaskRay brings to managing dates. Initially, we thought that just adding time fields to the Task object would be all thatโ€™s required. But another requirement was that different timezones be supported and take advantage of DayBack’s enhanced timezone support.

Unfortunately, the time fields in Salesforce are โ€œfloatingโ€ and donโ€™t reflect a specific UTC value that can be interpreted across timezones. The only Salesforce fields that work this way are Date/Time fields. They’re stored as UTC values and then displayed with the appropriate time for each user depending on the timezone specified in the org or userโ€™s settings. This meant that we needed to add new Date/Time fields to the Task object and then keep the date part of them in sync with TaskRayโ€™s native date fields.

We added the two new Date/Time fields: Start Date Time (Start_Date_Time__c) and Estimated End Date Time (Estimated_End_Date_Time__c). We also added a checkbox field for flagging a Task as an All Day task as this is not implicit in Date/Time fields by themselves.

Using An Apex Trigger To Keep Dates and Date/Times Synchronized

We had looked at using Process Builder or Flows to keep the dates and Date/Times in sync, but timezone support is limited, and thereโ€™s no support for daylight savings using either of these methods, so we needed to use Apex for this. Fortunately, Apex has robust support for both timezones and daylight savings using the TimeZone class and getOffset method, which accounts for DST correctly. This allowed us to create an Apex Trigger that would update the Date/Times correctly if the dates were edited and update the dates if the Date/Times were edited.

We specified default values for times (if they hadnโ€™t yet been set) and made sure all new tasks had the All Day checkbox turned on by default, so this didnโ€™t affect the user experience. If times had been specified for the task and the date was updated, then the trigger updates the date portion of the Date/Time, keeping the specified time values the same. You can download the trigger as well as the test class which provides 100% code coverage: https://archive.seedcode.com/TaskRay/Apex.zip

Now that the dates and Date/Times are being synchronized, our customer could quickly assign times to the tasks by dragging them from the all-day section in DayBack to the appropriate time block. (Dragging tasks into a time slot sets the new Date/Time fields and unchecks the all-day checkbox.)

TaskRay Timezones
Assigning Times to Tasks in DayBack via Drag and Drop

We can also see that the TaskRay date fields are updated accordingly from the new Date/Time fields so all of TaskRayโ€™s native functionality remains intact.

Customize TaskRay
Dates and Date/Times are Synchronized

Soft Roll-out with Formula Fields

To start using DayBack with this configuration, we need to have values in the new Date/Time fields and checkbox. This could have been done using Salesforceโ€™s Data Loader, but another option is to create formula fields for the new fields and the checkbox. These formula fields will look to see if there are values set for the new fields and use those values if they’re present. Otherwise, they will return default values. These formula fields will be populated right away and mapped to the appropriate fields in DayBack without having to do a backfill for existing records.

The formula field for the all-day checkbox can infer that a Task is all-day if the Start_Date_Time__c hasnโ€™t been populated yet, even though the static checkbox field for all-day isnโ€™t checked. It looks like this:

IF( All_Day_Task__c , true, 
  IF ( ISNULL( Start_Date_Time__c ) , true , All_Day_Task__c )
)

For the start and end Date/Times, we can take a similar approach and use formula fields that look like this.

IF( ISNULL( Start_Date_Time__c ) , DATETIMEVALUE( TEXT( TASKRAY__trStartDate__c ) & " 19:00:00") , Start_Date_Time__c )

We do need to provide a default time value, but since all tasks will start as all-day by default, they really donโ€™t affect the user experience since users will be specifying a specific Date/Time when changing them from all-day either in DayBack or in the native TaskRay layout. Eventually, an administrator could determine that all non-archived tasks were created with the new configuration and remove the formula fields. They’d then re-map the static fields in DayBack, but thereโ€™s not really any downside to keeping the formula fields in place indefinitely.

We can then set up a simple On Event Save Custom Event Action in DayBack that will prevent DayBack from attempting to edit the formula fields (which would result in an error) and edit the new fields that the formula fields reference. The On Save action looks like this:

if(changesObject.start){
  //update the source date time field for start and not the formula
  changesObject.Start_Date_Time__c = changesObject.start.format();
  delete changesObject.start;
}

if(changesObject.end) {
  //update the source date time field for end and not the formula
  //offset the end if all day as Salesforce does not make midnight exclusive 
  var adjustedEnd = editEvent.allDay ? moment(changesObject.end).subtract(1,'days').format() : changesObject.end.format();
  changesObject.Estimated_End_Date_Time__c = adjustedEnd;
  delete changesObject.end;
}

if( changesObject.allDay === true || changesObject.allDay === false){
  //if the allday checkbox is edited, then edit the actual all day field instead of the formula field
  changesObject.All_Day_Task__c = changesObject.allDay;
  delete changesObject.allDay;
}
else{
    //explicitly update the checkbox field if it's not changed as the formula value will get updated
    //if there's an actual start date time
    changesObject.All_Day_Task__c = editEvent.allDay;
}

Benefits to Customizing TaskRay

DayBack can provide powerful new views to TaskRay for managing resources, whether sticking with TaskRayโ€™s native date-only configuration or extending it with Date/Time fields. Although there are some challenges around Timezones and Daylight Savings when incorporating Date/Time fields, Apex triggers and DayBackโ€™s Custom Event Actions provide us with the tools to do this seamlessly without disrupting all the powerful features TaskRay provides.


Going Further

Need help with this mod? Dive in using the code above or get in touch and we can add this to your org as part of an implementation package.

Learn more about TaskRay. Big thanks to Mike Davis at TaskRay for his encouragement and help with this article. You’ll find TaskRay on Salesforce AppExchage with over 250 five-star reviews!

TaskRay on Salesforce AppExchange
Learn More About TaskRay

Written by Jason Young · Categorized: Dev, Integrations, Salesforce · Tagged: For Developers, Resource scheduling, Salesforce

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Search

Latest Posts

  • Visual Buffers: See Your Actual Capacity
  • Adding Jobs to a Route in Salesforce
  • Scheduling Teams and Equipment
  • Visualize Skill Matching and Suitability
  • Visually Control Your Availability

Pinned Posts

  • Scheduling Recommendations in Salesforce
  • Scarcity: the Science of Resource Scheduling
  • Calendars Tell Stories
  • Time Shame – Plan Your Day Like a Road Trip
  • We Can’t See Late

I'm Interested

  • Facebook
  • Instagram
  • LinkedIn
  • Vimeo

© SeedCode, Inc. 2013–2026
+1 (855) 733-3263
who shot this?

X

View Details
Keep me informed
Which calendar sources interest you?
Interested in a calendar source we haven't listed? Have a question for us? Please let us know.
Loading