


The Utility returns a response that has a number of attributes you can use as you wish The method will thrown a runtime error if this second datetime is not provided. This is only used when performing a BusinessHours.diff calculation. This is optional on all methods and assuming you provide a valid timezone code you can have the resulting datetime value returned to you in the timezone provided. The expectation is that you’re passing in a string describing a java simple date format pattern. This is optional on all method calls, allowing you to manipulate the format of the returned result. Any method where you’re needing to pass in a numerical value. This is populated with a number when using the addSeconds, addDays etc. The format of a Flow datetime string is like this ‘, 3:47 pm’ or the pattern ‘dd/mm/yyyy, hh:mm:ss a’. Typically from a datetime input field for example. This is mandatory and is the Flow datetime variable you want to manipulate. So where Salesforce calls a method ‘addDays()’ you’d just use ‘addDays’. The method names used in the class are exactly as they’re documented in the formal Salesforce documentation, just without the brackets. This is mandatory and if not valid the logic will error out with an invalid method name error at runtime. The following attributes can be configured once you’ve created the action using either of the DatetimeUtility or DateUtility Classes If its not intuitive enough let me know and I’ll expand the documentation. There are 3 to 4 attributes to populate depending on which method you wish to call. Once selected, you’ll want to configure some attributes.

Once installed just reference the DatetimeUtility or DateUtility class from within Flow Builder Action to access Datetime and BusinessHours methods, or DateUtility class from a Flow Action to access the Date methods. For example, to use the dayOfWeek method you’d populate the action attribute ‘methodName’ with ‘Date.dayOfWeek’. To access the following Date Class methods, prefix the method you want to use with ‘ Date.‘. More information on Date Class methods can be found here. Was on a role by this stage so figured best to expose the Date Class methods as well.
DATETIME MINUS MINUTES APEX CODE
The way this code works is simple – Salesforce provides much more support in Apex for Datetime manipulation and Business Hours calcs, so the class included here simply serves to provide access to a subset of those Apex Datetime, Date and Business Hour class methods. The intent of this code is to be a gap filler until such time as Salesforce delivers more functionality. This Post was most recently updated on: 3/27/21Īt the moment Datetime and Business Hours are not particularly well supported in Salesforce Flows.
