I am working on the OOTB Milestones and now looking to calculate the Sum of the Elapse Time.

  1. How we can calculate the sum of all these Elapse Times using formula fields? Do I need to write some other logic ? As we all know we can not edit/update the CaseMilestones fields.
  2. In some cases, I only need to get the overall(End-to-End SLA) Elapse Time. So in this, I have to used Category & sub category value to differentiate from the another SLA's. How can I only get the 1st SLA elapse time ? Do I need to show Total Elapse time when all milestones are completed, right ?

enter image description here

How we can get the Elaspse Time of all Milestone attached to that case using SOQL ? Any guidance around this ?

1 Answer 1


You can do this upon executing following SOQL

SELECT SUM(ElapsedTimeInMins) 
From CaseMilestone 
WHERE CaseId = '<case id>' 
and IsCompleted = true

Refer CaseMilestone Object definition


You could limit your query to display the first record milestone record. You could also add case attributes (Category and Sub Category) in the filter.

SELECT CaseId, Case.Category__c,
FROM CaseMilestone  
WHERE CaseId='<case id>' AND IsCompleted=true 
AND Case.Category__c = '<my category>' LIMIT 1
  • The context of SLA handling is not clear from the question Commented Aug 9, 2017 at 19:13
  • find my updated answer to get the 1st SLA Commented Aug 10, 2017 at 15:18
  • Thanks, My Category & SubCategory is on the Case Object. How we can get that at the CaseMilestone query ? Commented Aug 10, 2017 at 15:37
  • sure !, please upvote the question too ! Commented Aug 10, 2017 at 16:46
  • 1
    you can put Order BY CreatedDate, so the first one you will get Commented Aug 15, 2017 at 18:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .