function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Auto entitlement check in salesforce via apex/visualforce code


 I have a requirement where in i need to perform a auto entitlement check whenever a case is created.
What i want to do exactly is as belows:-

Whenever a case is created , i need to check whether the product in that case is already covered/supported by any exisiting entitlement or not. If it is supported then show the matching list and the automatically map it to the entitlement.  

To be more specific , i need to check that both the accounts and the product related with the case are covered under any service contract. if they are covered under any service contract then they will not be billed, and the billing type field value would change to "contract". Iif they are not covered under service contract then they will be billed.

Please help me the scenaro. I am stuck here as i dont know how to start the process itself. what  all should i need to do to achieve this. i mean should i right a rule or should i right a trigger or apex class? Help me move forward in the right direction with respect to the above scenario.   

P.s :- There is a software called Service Max which does this feature. Need to replicate the same in my org. 
sharathchandra thukkanisharathchandra thukkani
in your case if user need to select the matching list then you need to go with visual force page.

If you want it automatically you can use trigger.

//Create trigger on case event should be before insert

//query for the product whether it is in any price book, based on the price book retrived query on the contract with price book value in teh where condition.

// once you get the contract you can check wether it has entitlement associated to it and assign it to EntitlementId of case. If not write the logic to assign that product to particular price book which has valid entitlement.

//when you get all values assign them properly in the case before insert trigger.