How to stop recurrence milestone in apex

2018-02-16 02:55:45

Hi I am using sequential milestone in our project.

We also have initial response and resolution time milestones working on case.

Sequential milestone we used to send an update to the customer between specified time. so when we send first update it gets stopped and reschedule again. It works perfectly.

The problem is when case is closed at that time resolution time milestone is get stopped but update(sequential) milestone still running. It doesn't make any sense to send the update when case is closed

Could anyone provide me the solution how to stop this sequential milestone completely after closing the case??

I faced this issue earlier. Generally, you can close the Milestones by a trigger that automatically marks milestones Completed on cases that match unique criteria. But in case of Sequential Milestone, it will create another Milestone as soon as you close one. To resolve this, I removed the Entitlement from the Case as soon as it closes. It worked for me.

Exa

  • I faced this issue earlier. Generally, you can close the Milestones by a trigger that automatically marks milestones Completed on cases that match unique criteria. But in case of Sequential Milestone, it will create another Milestone as soon as you close one. To resolve this, I removed the Entitlement from the Case as soon as it closes. It worked for me.

    Examples as mentioned in the Salesforce Help Article. The change I made is c.EntitlementId = null;

    Trigger

    trigger CompleteResolutionTimeMilestone on Case (before update) {

    if (UserInfo.getUserType() == 'Standard'){

    DateTime completionDate = System.now();

    List updateCases = new List();

    for (Case c : Trigger.new){

    if (((c.isClosed == true)||(c.Status == 'Closed'))&&((c.SlaStartDate <= completionDate)&&(c.SlaExitDate == null))){

    updateCases.add(c.Id);

    c.EntitlementId = null;

    }

    }

    if (updateCases.isEmpty() == false){

    2018-02-16 02:58:02