You need to sign in to do that
Don't have an account?
Martina Dimitrieva 2
How to check how many future callouts are left in my org
Hi, guys,
I would like to check how many future callouts are left in my organization. I know that Salesforce solution to check how many asynchronous apex executions are available is by making a request to the Rest API limits, but that's not helping me.
My situation is this:
I'm checking before every future callout will I hit limitations. I am doing that by making a query to the AsyncApexJob object where I count all the objects of this type which are with a creation date equal to Datetime.now().addHours(-24) and where JobType is equal to Future.
Something like this: SELECT COUNT() FROM AsyncApexJob WHERE CreatedDate >= :Datetime.now().addHours(-24) and JobType = "Future";
But AsyncApexJob object can have more than 200 000 records and I am hitting another limit if I am following Salesforce recommendation to check before every callout.
Also, the Limit class is not helping me too, because I need organization-wide limits, which is 250 000 callouts or users*200, the limit class only gives me the limits in the current apex context.
So do you have any idea how can I resolve this problem?
Best Regards,
I would like to check how many future callouts are left in my organization. I know that Salesforce solution to check how many asynchronous apex executions are available is by making a request to the Rest API limits, but that's not helping me.
My situation is this:
I'm checking before every future callout will I hit limitations. I am doing that by making a query to the AsyncApexJob object where I count all the objects of this type which are with a creation date equal to Datetime.now().addHours(-24) and where JobType is equal to Future.
Something like this: SELECT COUNT() FROM AsyncApexJob WHERE CreatedDate >= :Datetime.now().addHours(-24) and JobType = "Future";
But AsyncApexJob object can have more than 200 000 records and I am hitting another limit if I am following Salesforce recommendation to check before every callout.
Also, the Limit class is not helping me too, because I need organization-wide limits, which is 250 000 callouts or users*200, the limit class only gives me the limits in the current apex context.
So do you have any idea how can I resolve this problem?
Best Regards,
https://salesforce.stackexchange.com/questions/3380/how-can-i-determine-how-many-future-calls-have-been-executed-in-24-hours
2 , You can use REST Resouce Limits RI /vXX.X/limits/
That's not helping me. Let me explain why.
I am using this method: to check how many future callouts are left for 24 hours, but the problem is that I am doing this check before every future callout so I can be sure that there are left future callouts. So if I use REST API I need this callout to be async and the only way to do it is with a future callout, but before I do that, I have to make sure that there are left future callout, otherwise, if there are 0 future callouts left I will hit the limit. But when I execute this method GetNumFutureCallsInLast24Hours(), SF is giving me an error because the AsyncApexJob table contains more than 200 000 records or more.
I need another approach to this problem.