salesforceapex-codesalesforce-service-cloudsalesforce-communities

How to resolve a Salesforce flow error where Flow calls an apex class


I have a flow which calls an apex class and here is execution logs error,how to resolve this error

Error Occurred During Flow "ServiceAppointment_API": An Apex error occurred: System.AsyncException:

Warning: Approaching hourly email limit for this flow.
Each flow in your organization is limited to 100 error emails per hour. Since 12:00 PM, Salesforce has sent 99 error emails for ServiceAppointment_API flow. After 100 emails, Salesforce suppresses all error emails for this flow. The limit resets at 1:00 PM.
Error element myWaitEvent_myWait_myRule_3_event_0_SA1 (FlowActionCall).
An Apex error occurred: System.AsyncException: You've exceeded the limit of 100 jobs in the flex queue for org 00D36000000rhGR.
 Wait for some of your batch jobs to finish before adding more. To monitor and reorder jobs, use the Apex Flex Queue page in Setup.

Your helps is appreciated

Regards, Carolyn


Solution

  • The apex class schedules some asynchronous (background) processing. Could be a batch job, could be method annotated with @future or something called Queue able. You can have up to 100 of these submitted and up to 5 active (running) at given time.

    It's hard to say how to fix without seeing the code.

    Maybe the @future isnt needed, the developer meant well but something went wrong. Maybe it has to be async but could be done with time-based workflow or scheduled action in process builder? Maybe it's legit your bug, that code could be rewritten to work faster or process more than 1 record at a time. Maybe it's not your fault, maybe there's a managed package that scheduled lots of jobs and next ones fail to submit. Maybe you'll need to consider a rewrite that detaches it but more. Say instead of almost instant processing - have code that runs every 5 minutes, checks if there's something recently changed that needs processing and does it.