How to insert CaseMilestone in Salesforce

Sometimes we get such a scenario, we may need to create CaseMilestones– especially when you are doing data migration from Salesforce-to-Salesforce; but Salesforce does not allow to create CaseMilestone through custom means.

But we can follow the below steps to insert it in new org same as we have in current org (assuming that you have setup Entitlement and Milestone in new org same as existing org)

Create case with Entitlement with these key fields

We need to populate following fields on Case while moving/creating case.

SlaStartDate = Provide date from existing case or a new date

EntitlementId = <Provide Id of related Entitlement>

IsStopped  = <can be set to pause the milestone- especially for active milestones. Later we can resume this by setting value to false>

NOTE:

If we provide Entitlement Field while creating the case as mentioned above, system automatically creates related Milestone with StartDate as SlaStartDate of Case record. Now you can update the completion date of CaseMilestone record same as Completion Date of existing CaseMilestone in old org.