2

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 ?

| improve this question | | | | |
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

Update

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,
    CompletionDate,
    CreatedDate,
    ElapsedTimeInMins,Id,
    IsCompleted,
    IsDeleted,
    IsViolated,
    MilestoneTypeId,
    MilestoneType.Name, 
    StartDate 
FROM CaseMilestone  
WHERE CaseId='<case id>' AND IsCompleted=true 
AND Case.Category__c = '<my category>' LIMIT 1
| improve this answer | | | | |
  • The context of SLA handling is not clear from the question – Santanu Boral Aug 9 '17 at 19:13
  • find my updated answer to get the 1st SLA – Santanu Boral Aug 10 '17 at 15:18
  • Thanks, My Category & SubCategory is on the Case Object. How we can get that at the CaseMilestone query ? – user4567570 Aug 10 '17 at 15:37
  • sure !, please upvote the question too ! – user4567570 Aug 10 '17 at 16:46
  • 1
    you can put Order BY CreatedDate, so the first one you will get – Santanu Boral Aug 15 '17 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.