Design a trigger to automatically assign new Case records to specific users based on the Case's Type field. For example, Cases of type 'Technical Support' should be assigned to User A, and Cases of type 'Billing' should be assigned to User B.
Hii,
It's better if you share the approach you followed.
However, you can use something like this in your trigger handler
//You can fetch the user Ids through query and use them instead of hardcoding
Id userAId = 'xxxxxxxxxxxx'; // User A's Salesforce ID
Id userBId = 'xxxxxxxxxxxx'; // User B's Salesforce ID
// Loop through all the Case records being inserted
for (Case newCase : Trigger.new) {
// Check the 'Type' field to determine which user should be assigned
if (newCase.Type == 'Technical Support') {
newCase.OwnerId = userAId; // Assign to User A
} else if (newCase.Type == 'Billing') {
newCase.OwnerId = userBId; // Assign to User B
} else {
// newCase.OwnerId = defaultUserId;
}
}