0

Assume I have 10 milestones running on the Case under a single Entitlement Process.

  • how can we check if all milestones are completed on that case ?
  • How can we calculate the Total ElapseTime and show it in the Custom Field on the case layout ? Do I need to used formula field or the trigger logic ?
  • I have End-to-end SLA and some SLA within the main SLA. In order to calculate the ElapseTime of the SLA, I only need to consider the main SLA (not other SLA/Sub SLA which are running with main SLA). How can we differentiate those SLA based on Category & SubCategory ? Do I need to write whole logic trigger ?

Any guidance around this ?

| improve this question | | | | |
2

how can we check if all milestones are completed on that case ?

You could query and check isCompleted values

SELECT CaseId,
    CompletionDate,
    CreatedDate,
    ElapsedTimeInMins,Id,
    IsCompleted,
    IsDeleted,
    IsViolated,
    MilestoneTypeId,
    MilestoneType.Name, 
    StartDate 
FROM CaseMilestone  
WHERE CaseId='<case id>'

How can we calculate the Total ElapseTime and show it in the Custom Field on the case layout ? Do I need to used formula field or the trigger logic ?

You need to trigger an after update trigger, when the status is getting completed then fire this query and update that custom field.

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

I have End-to-end SLA and some SLA within the main SLA. In order to calculate the ElapseTime of the SLA, I only need to consider the main SLA (not other SLA/Sub SLA which are running with main SLA). How can we differentiate those SLA based on Category & SubCategory ? Do I need to write whole logic trigger ?

Yes, you need to write logic in trigger. To retrieve milestones based on Category and SubCategory use this query:

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>' 
| improve this answer | | | | |
  • On 1st query response, I agree this will either give me all Milestones attached to the Case with both values Yes/No. So are you suggesting that do I need to programmatically decide in trigger and keep checking if all SLA are completed ? Please clarify. – user4567570 Aug 10 '17 at 18:50
  • yes, better to check from code, specifically, when case status is getting closed/completed – Santanu Boral Aug 10 '17 at 18:52
  • It make sense to populate that ElapseTime summation only when Case is closed ? or anyway we can do summation for those SLA which are closed and keep checking till all SLA gets closed ? – user4567570 Aug 10 '17 at 18:57
  • it depends on your business requirement, specially reporting requirements when you try to show case handling in Business Hours and not actual hours. Hope it makes sense! – Santanu Boral Aug 10 '17 at 18:59
  • for 3rd query, I see the only aggregate expressions use field aliasing Please modify the query – user4567570 Aug 10 '17 at 19:00

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.