Take Advantage of the New Custom Time Field in Spring ’18

By

In Spring ’18, we released a new custom time field as an open beta. It means that this new field type will be available in both production and sandbox orgs. While it’s marked as ‘Beta’, this is a high-quality feature that is safe to use. However, there are a few limitations that you should be aware of and those can be found in our release notes.

What is the Custom Time Field?

The time field is a new addition to the widely used Date and DateTime fields. Now you can store specific times independently from a date. Time field allows you to store time as an independent value. You can think about it as the time on a wall clock—it is that particular time where you are, regardless of what time it is somewhere else in the world.

The time field comes as a separate field type, and also as a new return type for your formula fields. So, you can create a formula field that will return a time value.

Let’s look at a use case example of how to use this new field: You run a hotel empire and would like to get some insight into how early or late people check in and out from each of your properties. You can store check in and check out times for each of your hotels as a time field. And, check in times are always stored in local time so it doesn’t require a time zone adjustment. It’s a perfect use case!


Now that you have this information stored, let’s take a look at how we can leverage it in formula fields and validation rules.

Formulas and Validation Rules

So, let’s get to the fun part! The time field comes with a set of handy formula functions. Say for each check in/check out, you want to know how early or late it happened. To accomplish this, every time a customer checks in or out a hotel receptionist needs to create a record to specify when that event happened.

You can also create a simple formula to calculate how much earlier or later than the appointed time the check in or check out happened.

IF( ISPICKVAL(Type__c , "Check In") ,
Hotel__r.Check_In_Time__c - Time__c,
Hotel__r.Check_Out_Time__c - Time__c) / 3600000

(Note: this formula will return the time difference in milliseconds; this is why we convert it to hours by dividing by 3,600,000.)

Now, let’s use time fields in validation rules. Your hotels charge a late check out fee, and you want to make sure that hotel staff doesn’t forget to apply that fee. So, if a check out happens more than 2 hours after the official check out time, you want to show a validation error (unless the customer already paid that fee or it was waived for them).

Here’s a validation rule formula that will do the trick for you.

IF( ISPICKVAL( Event_Type__c , "Check Out"),
IF( Late_Check_Out_Approved__c = FALSE,
IF( (Hotel__r.Check_Out_Time__c + 720000) < Time__c, TRUE, FALSE),
FALSE),
FALSE)

Some other handy time functions to consider:

  • TIMEVALUE()
  • MILLISECOND(), SECOND(), MINUTE(), HOUR()

Resources

Now you can apply these simple examples in your org to solve your own business scenarios! If you want to learn more, check out the Spring ’18 release notes. You can also join other time field Trailblazers in our Trailblazer Community dedicated to the time field where you can ask questions and provide feedback. And, don’t forget to check out Date/Time formula Trailhead unit!

Protect data With Private Connect for Data Cloud

Enhance Agentforce Data Security With Private Connect for Data Cloud

In today’s digital landscape, ensuring the security of customer data is one of the top priorities for Salesforce Admins. With the increasing frequency of security breaches, the need for robust protection of sensitive information is more critical than ever. Exposing services to the public internet inherently opens up vulnerabilities that can lead to unauthorized access, […]

READ MORE
Modular Flows + Agentforce for Smarter Automation

Embrace Modular Flows to Build Smarter Automation for Agentforce

Automation is one of our superpowers as Salesforce Admins, and modular flows make that power even stronger. If you’ve noticed, flows are everywhere! Your flow-building expertise is key to preparing your company for Agentforce by creating custom flow actions for agents. However, as we shift toward building autonomous agents, we must rethink our approach from […]

READ MORE
key 2024 takeaways for Salesforce Admins

Key 2024 Takeaways for Salesforce Admins: Agentforce, Flow, and More

As 2024 comes to a close, it’s time to reflect on all that Salesforce Admins have accomplished. ✅ This year was packed with innovation, and one of the standout milestones was the launch of Agentforce, Salesforce’s new suite of assistive and autonomous agents. With Agentforce, you can build, customize, and deploy intelligent agents tailored to […]

READ MORE