[SalesForce] Set Case Milestone to completed on Case Creation

Ive been using the following example to complete milestones on Case Close which works fine when editing an existing Case.

https://help.salesforce.com/articleView?id=entitlements_milestones_trigger.htm&type=5

However, this doesn't work when the rep creates a case and immediately marks it as closed as the Milestones do do exist at that point. I've tried using @future to execute the milestone logic after the case and milestones have been created, however, i then hit this error:

"You can’t change the completion date on a milestone that’s already exited an entitlement process.: Completion Date: [CompletionDate]”

Any suggestions on how to complete milestones when a Case is closed on insert?

Best Answer

Edit the entitlement process to have an exit criteria other than "on close", that way the case won't exit the entitlement process, you can close the milestone and then exit the process.

I have the same problem but a slightly different root cause.

Related Topic