This trigger dynamically sets the Priority of a Case based on its Origin. If the Origin is “Phone,” the Priority is set to “High.” Otherwise, it defaults to “Low.” This approach ensures effective case handling based on urgency.
For more examples, visit this YouTube playlist.
Solution:
trigger CaseTrigger on Case (before insert) {
if(Trigger.isBefore && Trigger.isInsert) {
for (Case caseRecord : Trigger.NEW) {
if (caseRecord.CaseOrigin == ‘Phone’) {
caseRecord.Priority = ‘High’;
}
else{
caseRecord.Priority = ‘Low’;
}
}
}
}