[SalesForce] How to avoid Apex CPU time limit exceeded error with Process Builder

We have multiple rules setup for Case using process builder but one of the rule seems to be failing throwing CPU Time Limit Exceeded error. The process is failing at this step where i am updating OwnerID with LastModifiedById since there are a total of 5 million Cases.

enter image description here

enter image description here

enter image description here

I would like to know if there's a way to call a batch class in the immediate action leaving the criteria as-is? How can i query the cases in batch apex that i could call here in the process builder?

Thanks in advance.

Best Answer

CPU time limit is exceeding due to processing of large number of records with given logic. https://welkinsuite.com/blog/how-to-get-past-apex-cpu-limits/

Apart from this, you can call Batch class from Process builder or Trigger. You can try with Batch from Trigger and run it Async. Using Code you can put your logic to filter out only those records need to be updated.