Field Service (formerly known as Field Service Lightning) gives you a powerful, highly customizable, mobile-friendly field service hub in Salesforce. When Field Service is enabled, you gain access to a suite of standard objects that you can find in Setup and as tabs in Salesforce. These objects make up the core Field Service features, including work orders and service appointments.
Many of the Field Service objects have a lookup reference to either the Account or Contact object or in some instances, to both of them. As the Local Time App already supports time zones on Accounts and Contacts, one easy low-code option is to create formula fields on the Field Service objects to get the time zone information from the related Account or Contact records.
In this article, we will use the ServiceAppointment object as an example. The ServiceAppointment has lookup fields to both Account and Contact objects. We will use Account field in our example and you can easily extend this logic to Contact field if needed.
Examples
- To get the time zone value from the related account, use Account.tz__Timezone_F__c in an existing formula field or in a new formula field.
- You can do the same with other fields in the Account object. For instance, to get the UTC Offset value from the related account, use Account.tz__UTC_Offset_F__c in an existing formula field or in a new formula field.
Moreover, the ServiceAppointment object has many Datetime fields such as SchedStartTime, SchedEndTime. The values for these fields are usually displayed in the Salesforce user’s time zone. However, the related Account record could be in a different time zone. Thus, in some instances, it will be useful to also show these Datetime field in the related record’s time zone.
For example, if you would like to show SchedStartTime (Label: Scheduled Start) value in the related Account time zone, you can do as follows:
- Create a formula field (returning Text data type), say, Scheduled_Start_Date__c.
- Place the following formula in the formula field and Save it.
IF(ISBLANK(Account.tz__UTC_Offset_F__c), "Unknown", MID( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 6, 2 ) & "/" & MID( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 9, 2 ) & "/" & LEFT( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 4 ) & " " & TEXT( IF( OR( VALUE( MID( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 12, 2 ) ) = 0, VALUE( MID( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 12, 2 ) ) = 12 ), 12, VALUE( MID( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 12, 2 ) ) - IF( VALUE( MID( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 12, 2 ) ) < 12, 0, 12 ) ) ) &":"& MID( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 15, 2 ) &" "& IF( VALUE( MID( TEXT( SchedStartTime+ Account.tz__UTC_Offset_F__c /24 ), 12, 2 ) ) < 12, "AM", "PM" ) & " " & Account.tz__Timezone_F__c )
- If you prefer, add this field to the page layout.
- The Scheduled_Start_Date__c will now show the SchedStartTime in the related Account’s time zone.
Summary
In this article, we illustrated how you can leverage formula fields to easily surface time zone information on Salesforce Field Service objects. A limitation with this approach is that the time zone values obtained from the related record are “as of now” and thus this method does not account for any Daylight Saving Time (DST) changes in the future. Thus if your Scheduled Start value is in the future (crossing the DST), the formula still uses the current time zone and UTC Offset fields, instead of using the time zone and UTC Offset values that are relevant for the future date. As a consequence, the calculated Scheduled Start Date value could be potentially off by an hour.
In the next article: How to Show Time Zone Information on Salesforce Field Service Records? – Part 2, we will present a code based solution that overcomes this limitation.