Problem

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

  1. The case trigger has been deployed to your salesforce instance, and the provided beforeInsert method will be invoked for the "before insert" event.
  2. Use trigger context variables (i.e., trigger.new) to access the records from the trigger handler.

Example

//PriorityAccount
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

The "Account" and "Cases" are standard objects in salesforce, connected through a lookup relationship. Cases have a standard field named "Account" with the API name "accountid".

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.