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
Rajesh T 19Rajesh T 19 

What are all the possible ways in catch block to Notify the users if the Apex CPU time limit issue happens in the future method ?

In my scenario, when calling the future methods has heavy loads it leads to Apex CPU time limit issue. I need to send the process result to users so if someone knows please help me on how to achieve this  if CPU time limit issue occurs.
Suraj Tripathi 47Suraj Tripathi 47
Hi Rajesh,

Becoz your Apex execution time is too long, it's limit exceeded that's why error thrown. The salesforce limit exceeded.
The Maximum CPU time on the salesforce servers - 10,000 milliseconds (Synchronous limit) 60,000 milliseconds(Asynchronous limit)

SInce your code execution takes a lot of time than allowed limit, try refining your code by removing unnecessary for loop, for loop inside for loop. Utilize sets,maps advantages and refine your code. Also you can move the piece of code that does not need to be executed in the same context to future method. 
 
In case you find any other issue please mention. 
If you find your Solution then mark this as the best answer. 

Thanks and Regards
Suraj Tripathi.
Rajesh T 19Rajesh T 19
Hi Suraj,

Yes, I understand but in my case I have refine the code in future method itself the only case is heavy data passed in future method parameter Apex CPU time limit issue Occurs but not with medium/low data passed. And my question is In catch method can we able to send email to runnning user to notify the transaction failed when CPU time limit issue occurs ? Whether system will trigger an email which email logic written in catch block ?