You need to sign in to do that
Don't have an account?
fiona gentry
Trigger for Case's Subject and change Owner To Queue
Dear Friends,
At a conceptual level, below is what Trigger code is doing
1 Query for Salesforce queue name Prepaid
2 Iterate over the Email 2 Case records for Record Type as "Executive Response " I get (from Trigger.new)
3 Calls .contains() on the Case's Subject to see if target word "Airtel" exists
4 Update the OwnerId to queue
Problem is i dont see the Case owner got changed to queue as Prepaid,can you suggest what mistake is there
Thanks In Advance
Regards
Fiona
At a conceptual level, below is what Trigger code is doing
1 Query for Salesforce queue name Prepaid
2 Iterate over the Email 2 Case records for Record Type as "Executive Response " I get (from Trigger.new)
3 Calls .contains() on the Case's Subject to see if target word "Airtel" exists
4 Update the OwnerId to queue
trigger PrepaidEmailSubjectAsw on Case (before insert) { if(Trigger.isBefore && Trigger.isDelete){ List<Group> lstPre = [SELECT Id from Group where Type = 'Queue' AND DeveloperNAME = 'Prepaid' LIMIT 1]; if(!lstPre.isEmpty()){ for (Case c : Trigger.new) { if(c.Subject!=Null && c.Subject.Contains('Airtel')==True && c.RecordType.Name == 'Executive Response'){ c.ownerId = lstPre[0].Id; } } update lstPre; } } }
Problem is i dont see the Case owner got changed to queue as Prepaid,can you suggest what mistake is there
Thanks In Advance
Regards
Fiona
you have written trigger event as before insert but you were executing the trigger in delete operation.
So you need to modify the trigger context variable from Trigger.isDelete to Trigger.isInsert
There is no need of DML operations on before insert/before update events.
try with below code.
If this helps, Please mark it as best answer.