function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DannyTKDannyTK 

Trigger to update new cases generated by Process Builder

Hello all, 

I'm trying to write a simple trigger to update new cases created by Process Builder (so assignment rules can re-assign, since these cases hit the rules until it's Edited and Saved manually).  So all the trigger would have to do is re-save the cases (with nothing else to change).  

what i have is: 

trigger caseUpdate on Case (after insert) {
    List<Id> idCase = new List<Id>{};
        for (Case ticket : Trigger.new) 
    update ticket;
  }

But this doesn't seem to work.  Can someone take a look and see where I went wrong?

thanks again community
-danny
Terence_ChiuTerence_Chiu
Danny, this article may help you with applying case assignment rules via Apex.

http://developer.force.com/cookbook/recipe/running-case-assignment-rules-from-apex
Fahad-AkhtarFahad-Akhtar
Try this and it should work
trigger caseUpdate on Case (after insert) {

	//Update records directly.	
    update [SELECT id FROM Case WHERE id IN: trigger.new];

  }

Thanks,
Fahad Akhtar
DannyTKDannyTK
Thanks Terence and Fahad,

I used both the Database.DMLOptions to utilize the assignment rule via trigger, as well as the simple update on new Cases...looks like neither worked.  I'll keep modifying, let me know if you have any other suggestions and I appreciate your help on this. 

-danny