Time Zone and Time Operations in Flow

Time and time zone operations in Salesforce are notoriously challenging due to the complexities of handling global users and varying time standards. While all system time fields in the Salesforce database are stored in GMT (Greenwich Mean Time), factors such as organization and user-specific settings, as well as Daylight Savings Time (DST), add layers of complexity. These settings affect how timestamps are displayed on records and transactions. The challenge grows further when working with external users, such as in a community page, where Salesforce cannot determine the guest user’s zone automatically. This post explores these challenges and highlights a practical solution for calculating time zone offsets, enabling accurate time conversions within flows.

SurveyVista: Effortless Data Collection to Action

What makes time and time zone operations very difficult?

  • The organization’s time zones can be set up in the organization settings.
  • The user can have a different time zone than the organization.
  • Salesforce will use these settings to display the time to the user on the screen. Similarly, these parameters determine what the user sees when they view the timestamp on the records and the transactions.
  • Installed packages and additional functionality that run in your Salesforce Org can also have time settings. Field service lightning – FSL – is a famous example.
  • You may think you had enough. Not so fast. The DST – Daylight Savings Time – makes everything even more complicated.

Displaying Time to External Community Page Users

When you display the time in a screen flow running on an external community page to a guest user, Salesforce does not know the user’s time zone.

Even if Salesforce knew, there is no good way to get the user’s time zone or their current local time within the flow. The behavior can depend on what context – user vs. system – you are running your flow in.

This means you need to do the time zone conversion yourself as the flow builder.

Finding Solutions Through Collaboration

A few months ago, I was on Eric Smith’s blog working on implementing the data-table flow component. I found an invocable action he wrote that returned the start of the day (midnight) for a particular date. I immediately asked what context the action ran because I built a flow for a Nonprofit before, and I had to jump through hoops to try and calculate the time in the correct time zone to be displayed via a community screen flow.

Free Mentorship With Talent Stacker

If this action could give me the correct start of the day in the user time zone, I could calculate a time offset for the system time GMT and convert all system times to the user’s time zone.

Needless to say, the solution worked, and that is why I am here writing about it. Eric Smith was super kind to post a detailed blog post about this. Please find it here.

The Takeaway

Using this method, you can calculate at any point in time what the offset – differential time in hours – is between the user’s time zone and GMT. This means you can use this number to convert all the system times to the user’s time zone before displaying them on the screen.

Explore related content:

Error Screen Message Design in Screen Flows

Assignment or Update

Mastering Get Elements in Salesforce SOQL Queries

Andy Engin Utkan

Andy Engin Utkan is a Salesforce MVP with 24 certifications. He is the founder of Salesforce Consulting Partner BRDPro Consulting. Utkan is a consultant, trainer, and content creator, focusing on automating business processes using Salesforce flow. He is recognized for his expertise in Salesforce flow, providing guidance through various courses and contributing actively to the Salesforce community.
Back to top button

Discover more from Salesforce Break

Subscribe now to keep reading and get access to the full archive.

Continue reading