A financial service company leveraging salesforce to log and manage customer requests is seeking enhancements in its case management processes.
The objective is to dynamically set the case priority based on the account rating when case records are inserted into salesforce. To achieve this goal, the salesforce team has decided to implement an apex trigger on case.
Complete the given apex trigger handler to satisfy this requirement.
Instructions
1. If the account rating is set to 'Hot', then set the case priority to 'High'.
2. If the account rating is 'Warm', then set the case priority to 'Medium'.
3. If the account rating is 'Cold', then set the case priority to 'Low'.
4. If an account is not linked to a case, do not process it further.
Note
- The case trigger has been deployed to your salesforce instance, and the provided beforeInsert method will be invoked for the "before insert" event.
- Use trigger context variables (i.e., trigger.new) to access the records from the trigger handler.
Example
Insert new Account (Rating='Hot',name='Amazon USA');
//newCase
Insert new case(AccountId=PriorityAccount.Id, Status='New');
//Result
The priority on newCase will be set to 'High'
Hint
In this scenario, the record that is inserted requires an update. Utilize the "before" trigger event to perform the update on the same object.
Ensure that the trigger code is bulkified, using appropriate variable types to prevent any potential breaches of governor limits.