+ Start a Discussion
Shawn ReichnerShawn Reichner 

Case Trigger Not Firing Approval Process


I have created a case trigger with the following code.....

trigger CaseApproval on Case (after insert, after update) {

    for (Case currentCase : Trigger.new) {
        if (currentCase.RecordType.Name == 'SF_Dev_Requests')
            Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
            req.setComments('Submitted for approval. Please approve.');
            Approval.ProcessResult result = Approval.process(req);

The trigger is not firing the approval processes when a case with the record type mentioned in the trigger code is created. 

Can someone please help me understand what may be causing the trigger to not fire, and help me resolve this issue to have these types of incoming cases auto start the approval process?

Thank you for all of your help in advance,

SonamSonam (Salesforce Developers) 
Hey Shawn, have you created the same approval process on the ORG through the UI? please confirm.

As is also stated in the blog:"For the trigger to work you need to have an approval process with matching criteria."
reference: http://blog.jeffdouglas.com/2010/01/04/automating-salesforce-approval-processes-with-apex-triggers/