You need to sign in to do that
Don't have an account?
jaishri
Run Case Assignment Rule From Apex
I'm getting issue in the below code can anyone help me where is wrong :- CaseAssignmentRuleTrigger: execution of BeforeInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, CaseAssignmentRuleTrigger: maximum trigger depth exceeded Case trigger event BeforeInsert
trigger CaseAssignmentRuleTrigger on Case (before insert,before update) { //Fetching the assignment rules on case AssignmentRule AR = new AssignmentRule(); AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1]; //Creating the DMLOptions for "Assign using active assignment rules" checkbox Database.DMLOptions dmlOpts = new Database.DMLOptions(); dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id; Case newCase = new Case(Status = 'New') ; //Setting the DMLOption on Case instance newCase.setOptions(dmlOpts); insert newCase ; }
If you dont have any conditions you can try the below trigger.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
Are you trying to insert new case using before trigger?
Thanks,
I want to create a case on community site if case is created it will automatically assign to that users.
Is there any condition on status to fire the assignment rule or it should fire always a record is updated or created?
Generally you should fire assigment rule in after context. please check the similar example on leads
If this solution helps, Please mark it as best answer.
Thanks,
there is only two rule entries in case - type and based on type there is subtype .In org side it is working fine but in experience sites it is not working the active assginment rule.
Thanks
As mentioned above you should not write in before context. It should be after update/after insert
Thanks,
Hi Sai,
same issue is coming .
If you dont have any conditions you can try the below trigger.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
Hi,
Is it possible to connect over gmeet to check. Same is working in my org.
Thanks
I cannot share personal email. But can share gmeet link once you join I will delete so no one else can join it.
Thanks,
Is the assignment rule satisfying the criteria of the record?
Thanks,
Thank you for your solution.