function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Eran VizelEran Vizel 

Access Entitlement Process from Apex

Hi all,

I'm building a class that implements Support.MilestoneTriggerTimeCalculator - as I want to put in a few milestones with dynamic time calculation. The tricky part - I want the calculation to base on constant time defined in other milestones of this entitlement process. Within the class I can obviously access the case and the entitlement in context, but I don't see how can I reach the entitlement process behind this case and entitlement, in order to get to its other milestone and grab the integers for the dynamic calculation of my dynamic milestones.

I ran into an object called SLAProcess which I think is the entitlement process, but the workbench doesn't show it has any child relationship with milestones.

Please advise,
Many thanks,
Eran
pconpcon
The object you are looking for is EntitlementProcess.  This is related to the Case object via the EntitlementId.  That entitlement is then paired with an SlaProcessId and that links to the EntitlementProcess.  If you are trying to get to Milestone information then you will want to get it from the CaseMilestone object.  However, it is important to note that the milestone criteria calculation happens after all triggers, workflows, processes, etc fire.  So to get to this you will have to use an @future call.  I have blogged about this procedure here [1].  Let me know if that does anything to help or if I've just muddied the water.

[1] http://blog.deadlypenguin.com/blog/2015/07/29/service-breach-time-displaying-it-on-the-case/