Take Salesforce Entitlements & Milestones to the Next Level with #LowCodeLove

Author: Kash Hussain, Senior Salesforce Consultant

Salesforce Entitlements and Milestones are an essential part of Salesforce Service Cloud and any administrator or consultant can tell you why: With #ClicksNotCode, companies can begin tracking how well they’re providing customer support and how well their service team is performing. The power and simplicity of #ServiceCloud makes it an industry favorite!

But eventually this happens; a company is smacked with a challenge that clicks cannot solve. You see, typically the Milestone Start Date Time and Milestone Target Date Time are based on the Case Open Date Time or Entitlement Process Start Date Time. Sound confusing? It actually makes complete sense, right? Typically, a company would want to start the clock on support milestones when the support case comes in…

Only this time, it’s different. Imagine you now have a company with an external system containing hundreds or thousands of time-related rules. In this arrangement, various attributes related to the case influence the resulting Milestone Target Date Time. (Think: Account Type, Subtype or Issue Type) This might sound a little daunting, at first. Rest assured, it’s not as complex as you’re probably imagining. Forewarning, though, there will be Apex ahead! As the title promised, we’re discussing ‘LowCodeLove.’ In such a situation as outlined, we will have to deviate from a point-and-click only setup and implement an Apex Class to inform the Time Trigger.

The beauty of this often passed over checkbox in the setup menu is that it allows companies to make use of all the great functionality embedded in standard Salesforce Entitlements and Milestones while simultaneously performing highly complex calculations Salesforce could have never anticipated.

Without lecturing you on every detail of how to implement a custom MilestoneTriggerTimeCalculator, let’s instead focus on five hard-won life lessons not so well documented in the Salesforce Developer Guide.

Lesson #1: The calculateMilestoneTriggerTime() method returns time in minutes. So if you are using the standard BusinessHours Class to find the difference between two dates (ie. start and end date), then you must convert milliseconds returned using the diff() method into minutes before returning a result in the MilestoneTriggerTimeCalculator.

Lesson #2: Any edit to the Case record while the Milestone criteria is met and the Milestone has not been completed will run the milestoneTrigger and subsequently recalculate the time. This is actually pretty cool because it guarantees an always accurate Milestone Target Date Time .

Lesson #3: Triggers are still not supported on the Case or Entitlement objects therefore rolling up the Target Date/Time onto the Case remains a challenge. Using a milestoneTrigger, you are able to update the Case and make use of the information available there to set any fields you want. (ie. stamping the Target Date/Time value into a field as a column on Case List Views) Companies love that one!

Lesson #4: If you’re planning on doing a data migration, the milestoneTrigger may run into SOQL query limits so to avoid this remember to control your batch sizes! To what degree will depend on the performance of your code but it goes without saying SOQL use in your Apex should be as optimized as possible. (ie. try to query Case, Entitlement and Business Hours details in a single query when/if possible).

Lesson #5: The milestoneTrigger will fail if a non-zero positive integer is not returned. And guess what, you cannot return null. Instead, you must use the standard Entitlement and Milestone evaluation criteria carefully to ensure your milestoneTrigger isn’t running when not required.

Of course, we are only scratching the surface but now you can see there is enormous potential to expand on the capabilities of Salesforce Entitlements and Milestones. With just a little #LowCodeLove, companies are able to enforce even the most complex business requirements while still enjoying all the benefits of out-of-the-box #ServiceCloud. And that makes us all happy!

Are you interested in implementing or optimizing Service Cloud for your company? Reach out to us!

    Contact Us

    Any questions, or comments get in touch below.