Sunday 2 November 2014

Salesforce Entitlement, Entitlement Process & Milestone Handling

Entitlement : 

Entitlements are the same as the normal objects we use in Salesforce like Account, Contacts etc.
Adding to it, its a child object to Case, Contracts etc.

Purpose of Entitlement in Salesforce is specifically for
  • Enforce service levels with time-dependent, automated processes that instruct agents how to resolve cases.
  • Defining Service levels.

Entitlement according to Salesforce-phere
Entitlement is driven by "Entitlement Process" Object (Look-up on Entitlement Object ) where we set "Milestones" and "Business Hours"

1. Milestones :- Milestones are actually automated time dependent workflow, which run on the time set by the user, in other words to automate the SLA, this is the key of whole Entitlement thing in Salesforce. You can define the actions in Milestone i.e. Field Update, Email Alerts same like normal workflow. 

2. Business Hours : It is used to define the limits of the Milestone Time that have been set by the user like working hours in which a case should be handled.

Enabling & Setting-up Entitlement

Go to Setup --> App Setup --> Customize --> Entitlement Management --> Entitlements

Click Check and Save

after saving you'll get this check according to your requirement and Save. Do check last check-box of Enable Milestone Feed Items, this will add milestone box in your feed item, where Milestone Status will be more visible to the users.

Now go to Entitlement Process create one Entitlement Process

Here is the Entitlement Process created

Above in the setup list there is Milestones, create one

Now create an Apex class, that will set the Trigger time for the milestone, create a custom Number field on Case named as "Milestone Time" and create this class which implements "Support.MilestoneTriggerTimeCalculator"

Now whatever will be the value in the this field will be set as Time trigger of Case Milestone
We will use this class, while adding Milestone with an Entitlement Process.

Now return back to Entitlement that we have created earlier and and down to it click "new" button in Milestone section, and fill the values same as shown in below

We have done all the setup for the Entitlement Process and Milestone
Now we will create an Entitlement Record, (Don't get confused with Entitlement Process and Entitlement)

Entitlement Process

System object that have Milestones and is used while creating Entitlement (API name SLAProcess ) record.


Its an object, that will be associated with Case. It is as normal as other objects like Account, Contact. This is used to attach Case Milestone to the object.

We will create Entitlement record now, that we will attach to the case, search for the Entitlement Tab and click  new, create a new record as shown below, as marked below these field should be field to make Entitlement active otherwise you can't attache it to the Case as shown Status Icon it green check that means its active, you need to provide Start Date  for it, Entitlement process also need to be provided otherwise no Milestone Time will be on the Case, after saving entitlement record you can see the Milestone will be visible under the Milestone.

Now go the case, in the below snapshot, all those field which is used in Entitlement process are shown, we will create a new record of Case and in the Entitlement Name we will put the record that we have created above,
There is a Timeline field on Case layout,which show scale view of the Time that have been setup. Modify the layout and set Case Milestone related list as well

If user didn't close the case or whatever is the procedure to be done to close the case then case will be Violated that automated process, and then Milestone Status will be change.

Look we are done with Entitlement and Milestone thing of Salesforce
You can Milestone actions as well, go to the Entitlement process and Click on the related Milestone of it where you can action like Field Update and Emails alerts etc.

The biggest problem I faced with this functionality when I tried writing trigger on Case Milestone Violation, and attaching other Milestone with the Case. you can write on case on check of "Milestone Status" field that when the status changed to Open violation. but attaching other Milestone on the violation of the first one is not happening.

This is what I learned while working with Entitlement and Milestone of Salesforce.
Thank you, any queries will be appreciated, keep learning-keep coding.

Happy Coding!


  1. This comment has been removed by the author.

  2. Is is possible to use code to copy the Milestone Target Date to a field on the Case? I don't think it's possible to create a Milestone trigger.

    1. It can be achieved I think, you need to query the milestone fields related to the case and then update the case.

  3. I have followed similar steps but my milestone class is not getting invoked and milestones are not creating , although it works well when I remove reference to milestone class. Is there any setup changes that I am missing?

    1. Milestones never gets created only entitlement gets created and milestones are assigned to the entitlements. Milestones are system object so you can't create them using apex.

  4. Hi,

    I have send the warning actions at regular interval till the milestone is completed.

    I tried to add multiple time triggers, but the limit to add time trigger on a single milestone gets exhausted.

    Could you please help me to implement the above.

    Thanks in advance.

    With Regards

    1. Hi Palak,
      Sending warning mails again and again is not a best practice, as you know because of the Salesforce limits you are facing issues, As a procedure send the warning before 1 hour then before 30 minutes and so on.

  5. This comment has been removed by a blog administrator.

  6. Milestone Order and Milestone Name SOQL in salesforce ?

    1. There is no field named Milestone Order and Milestone Name, Name field is only on MilestonType. For more details about the fields below are the links that can help

  7. I need to populate "TargetResponseInMins" field value from CaseMilestone onto Case Custom_Field__c when ever CaseMilestone is got created, How can i achieve this?