I have an Entitlement process and support triggers that I would like to test so that I can submit code into product.


When I create all the object through code I only get one of the Milestones out of three that I am expecting (First Response).

When I take the code out of test so that I can see what object are created I get the same result. However when I create a case manually using the objects created from the code (out of test) I get the three Milestones that I am expecting to be created for the case.

The two Milestones I am not seeing have a Start Time of "Entitlement Process", they are:

Restore SLA Case Priority equals Critical (1) AND Restore Point equals null


Resolve SLA Case Priority equals Critical (1) AND Closed not equal to True

(and the above with Priority High, Medium/Low).

Finding that if I let the "Priority" default (to low) I am seeing the Milestones I expect.

I am using the following to set Priority:

newCase.Priority = 'Critical (4)';

In the case created from code it is setting the priority correctly but not setting up Milestones as it should.

3 Answers 3


I confess I've never worked with Milestones. But if I understand correctly some kind of best match is being used (perhaps the first match if they're somehow ordered? Like in approval processes - you can have multiple approvals on 1 object, you need to set them in order and the first one that matches entry criteria is being used).

This help article says:

Salesforce assigns milestones with matching criteria to the case. For example, if a milestone's criteria is Priority equals High, and a case has a Priority of High, Salesforce assigns it to the Priority equals High milestone.

A case associates with one milestone at a time; it can associate with many milestones as it moves through the process.

I suspect you'll have to change values and update your Case record (maybe even more than once; or maybe you need more than 1 test record) to see it progressing through Milestones.


Well when you are creating case from the standard page I guess you are explicitly selecting value for "Entitlement Name" or "EntitlementId"(Api Name). While creating the same from code you have set the Entitlement Id by doing something like :
Case.EntitlementId = [SELECT Id,Name FROM Entitlement WHERE Name = 'My Entitlement'].Id


Priority setting problem:

newCase.Priority = 'Critical (4)';

Should be:

newCase.Priority = 'Critical (1)';

Surprised that some sort of error did not occur. It is always the little things. :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .