Questions tagged [future]

A future method runs in the background, asynchronously. You can call a future method for executing long-running operations, such as callouts to external Web services or any operation you’d like to run in its own thread, on its own time.

Filter by
Sorted by
Tagged with
6
votes
2answers
10k views

Calling future method from batch class?

I got a situation where i need to invoke future method from batch class. And i know that it is not possible to do. But there might be some workarounds to achieve it, right? And i dont want to invoke ...
6
votes
1answer
1k views

testing future with callout from schedulable class

I'm definitely missing something. How do I test Schedulable class with a future method that does a callout?I have 100% code coverage of the Schedulable class but 0% of my service.The test fails as no ...
6
votes
1answer
194 views

A callout pattern idea

I just came up with the following pattern for making callouts. It's loosely based on Dan Appleman's Scheduler pattern. Has anyone out there has used or dismissed this? Why did you dismiss it? How ...
6
votes
1answer
469 views

Async Callout Test Failing in Production

Situation I have implemented an API to communicate with the external system. After 18th of August test that i have on production have started failing showing the infamous: System.CalloutException: ...
5
votes
4answers
8k views

Pass List<SObject> to @Future

I have the following list in a trigger. list<Employees__c> employeesToUpdate = new list<Employees__c>(); I want to pass the list to a Future method. All I really need is the ID of the ...
5
votes
3answers
557 views

Field Describes in a Trigger causing scalability problems

I have a trigger (simplified sample code below) that is using field describes to determine what fields were changed to conditionally update some other field on the same record. The problem is that ...
5
votes
3answers
1k views

Confused by CalloutException

I have a trigger on Account and Opportunity - both do a callout to the Google Geocoding API and then update itself using a future method. Now I also want to send an email before the update if certain ...
5
votes
1answer
2k views

Help on Invokable Apex Test class and @Future callout Apex test Class

I am pretty new to Apex and trying to learn as much as possible. Any help would be really appreciated. I have two classes. Invokeable Apex Class: This class is just getting called by a Process (...
5
votes
1answer
2k views

Why can we not pass Sobjects as an parameter in future calls

I read in salesforce documents that Methods with the future annotation cannot take sObjects or objects as arguments. Can any one please explain why can we not pass Sobjects as an parameter in future ...
5
votes
1answer
2k views

Method does not exist or incorrect signature: void send(System.HttpRequest) from the type System.HttpRequest

Currently stuck at trying to send a JSON structure through web services but keep receiving the error: Method does not exist or incorrect signature: void send(System.HttpRequest) from the type System....
5
votes
1answer
288 views

How can I get around queued job limitations?

I'm writing a queueable class to perform some image optimizations. The class has to call out to AWS S3, get the source image, then call out to Kraken.io three times to optimize the source image, get a ...
5
votes
2answers
199 views

How to disable asynchronous jobs so that they cannot update data

There will be a data export happening from our org for large number of objects and records using a cloud based ETL tool. We have a business scenario where we need to make sure that there is no data ...
5
votes
1answer
1k views

Design Question: Any way around the "System.AsyncException: Future method cannot be called from a future or batch method" error in this situation?

Goal: Attempt to Authenticate then execute authenticated API request with minimal code in a componentized/modularized fashion. The Players: Helper_Outbound_API_Request: Standardized Flow which ...
5
votes
1answer
2k views

Session Cache Bug When in @future Context

We built a little framework around managing Session Cache. It wasn't until today we referenced some of the caching methods from a @future method. I understand that in this case it might be better to ...
5
votes
1answer
488 views

Is there a way to load an internal Salesforce page from a scheduled batch?

My end goal is to be able to send license usage as well as data/file storage usage from clients to our org. As these values don't appear to be available directly via any API calls, I had to resort to ...
5
votes
1answer
2k views

What happens when an exception is thrown within an asynchronous @future method?

I have a process builder flow which is triggered by opportunity creation and updates, and that flow executes a bit of apex code. It POSTs to an external service and sets a field on the opportunity: ...
5
votes
1answer
2k views

Update of Locked Records works in Future Calls

We have seen an interesting behaviour. When we call a method which tries to update locked records it failes with ENTITY_IS_LOCKED. When we call the same method as a future method it works! By design? ...
5
votes
2answers
1k views

Preventing Recursive Future Calls

I have a usecase where when an account is updated, an after update trigger is fired. This trigger will call a future method which will call a SOAP API to assign the relevant territory assignment rules....
4
votes
2answers
5k views

Diference between @future (callout= true / false)

I don't understand the difference between: @future (callout= true) and @future (callout= false) I have read the documentation, but I don't understand where to use one or the other.
4
votes
2answers
2k views

Is it possible to handle Trigger.oldMap in @future method?

I've got a class with an @future annotated method that gets called in an after Trigger context variable (it's an asynchronous callout, so it needs to be in Trigger.after) and performs Database.update(...
4
votes
1answer
2k views

Saleforce Too many future calls: 11

I have a business logic as follows. 1. A web service class parses XML file containing case data and loads the case to SF. 2. Trigger that on update of case email field make a call to future method ...
4
votes
1answer
2k views

Future Method to Trigger to Future Method

I was attempting to call a future callout method from a trigger and am getting the error that a future method can not be called from a future or batch method. The trigger is being called on insert of ...
4
votes
1answer
2k views

Can Process Builder run @future methods?

We're hitting CPU Time Limit Exceeded issues with a class that's being called by a Process Builder. From the SF solutions page, it was noted that one fix for CPU Time Limit Exceeded is to make the ...
4
votes
1answer
19k views

Static method cannot be referenced from a non static context in testclass

I am working on a testclass but get the error that my method cant be referenced from a non static context. I have a class where I insert a list of contacts followed by a @future method. I get the ...
4
votes
1answer
6k views

Future method cannot be called from a future or batch method: Error

I have two classes class A and class B, I am trying to call Class A's future method from class B's method and I get this error :'Future method cannot be called from a future or batch method'. Class A:...
4
votes
1answer
288 views

Using @future tag on Apex Webservice but code not executing asynchronously

With the winter '15 release over the weekend some mission critical code for us is now getting the infamous "Apex CPU time limit exceeded". It worked fine for the past 8 months until this release. (as ...
4
votes
1answer
2k views

System.AsyncException: No enclosing class for method: methodName

I have this error that says "System.AsyncException: No enclosing class for method: methodName". The code structure : trigger trgSendRecords on DataSetup__c (after insert) { /* SOME BUSINESS ...
4
votes
2answers
3k views

Recursive Future Method calls because of before update trigger

In my Lead object before update trigger whenever certain conditions are met, the trigger calls a future method (which makes a API call to a service). The value returned by this REST service needs to ...
4
votes
1answer
4k views

DML update in @future callout not updating sObject

I've got a Apex class that takes the data from an Account object and uses it to create an account in my company's database by hitting an API. The API accepts JSON then inserts all the appropriate ...
4
votes
2answers
1k views

Do asynchronous methods run in parallel?

The short question is - do future methods run in parallel, or sequentially? I am wondering if race is possible in Salesforce. Let's say We've got some singleton class S that we want to call from some ...
4
votes
1answer
5k views

unsupported parameter in future method

I am trying to create a future method and pass in the following parameter: @future private static void myMethod(Map<Id, List<String>> userMap) { I get unsupported parameter type. I can ...
4
votes
2answers
644 views

Concurrent HTTP callouts vs single callout

Background I have 3 identical HTTP servers, holding the same data: api1, api2 and api3. I want to query this data as reliable and quick as possible. In Java, I would have done this by spawning 3 ...
4
votes
1answer
511 views

Test Class - System.CalloutException: You have uncommitted work pending - Platform Event

I am using platform events and in one of the after triggers I am calling a method in a class where the method is annotated with @Future(Callout=true) In my test method below I am doing some DML to ...
4
votes
1answer
2k views

How to solve Async Future Method Inside Loops Issue?

Can any one please help me solving this, The below trigger will create an guid(random_string) and it will be passed to an controller and from controller i'm hitting the Post the data to our URL. ...
4
votes
3answers
2k views

Error in using multiple @future methods

I have created a Trigger and Class that works in dev environment, but I'm trying to deploy it to production, and it is testing all of my code with all the other classes in the environment. The only ...
4
votes
1answer
952 views

Trigger fired by future function does not support callout

I'm developing an integration that makes an HTTP call to an external system from SFDC. The entry point for this code is an opportunity trigger. After a user updates the opportunity, my trigger fires, ...
4
votes
1answer
234 views

What approach to take if one standard object need to use different @future call from API?

I am still new in Salesforce and have Java background.There some governor limit that I totally not sure what to do. The issue started when I need to update the Account object with the value that I ...
4
votes
1answer
1k views

Sandbox batch execution takes too long to be completed(simple task)

Is it true that running a batch class in Sandbox with incredibly simple task takes too long than Production? I've tried @future with the same task and it process my Streaming API immediately. Update:...
4
votes
1answer
1k views

Can you run Batch Apex after a callout?

I have a callout that is scheduled every hour to import data. Upon finishing the import, I would like to call a Bach Class that works with the imported data. Right now, I get an error saying Database....
4
votes
1answer
661 views

Is there a way to retrieve the oldMap of a trigger in a future method?

This could be quite a dumb question though, I would like to ask is there a way to retrieve the oldMap of a trigger in a @future method? In the below code please refer the collection "...
4
votes
0answers
119 views

compiling error during runtime for class that compiles fine

I'm getting the following error (below) while executing a future call. The mentioned class compiles and saves fine upon retesting. Any idea why this would be occurring at runtime? It seems to work ...
4
votes
0answers
167 views

Calling APEX out of JavaScript the APEX-API Version is ignored

I run in an issue with calling APEX out of JavaScript, when i call my APEX class, the class is executed with API-version 34.0, but in the metadata of this class is the API-version set to 27.0. I need ...
4
votes
1answer
3k views

Issue creating user and setting password

I am experiencing an issue creating users and setting their password. I have a need to setup a great deal of users but only activate them as they attempt to login. The creation process and activation ...
3
votes
2answers
2k views

Is there a limit on the maximum number of future jobs queued in an org?

I know there are certain limits with batch jobs, queued jobs, etc., but what about future jobs?
3
votes
1answer
80 views

Why would a future method not show up in debug logs?

What are some possible reasons a future method wouldn't show up in the debug logs? @Future(Callout=true) global static void myFutureCallout(Id testId){...
3
votes
1answer
2k views

How to check if future method has executed

in my apex code I need to do some calculation only when future method has executed I tried below code to check if future method has executed: public static void anotherMethod() { while('Completed' != ...
3
votes
2answers
4k views

Why salesforce has introduced Queueable Apex. need some proper clarification

future method behaviour - 1. is executed in their own thread 2. do not start untill resource are available 3. future callout gives us 200 asynchronous soql limit. Why we use Queueable Apex and in ...
3
votes
1answer
312 views

prevent trigger fire from a future method [duplicate]

I would like know if there is any global variable i can use to prevent trigger fire from a future method. Like I can use System.isBatch() to prevent trigger fire from batch classes
3
votes
3answers
524 views

How to mock System.isFuture()?

I am writing some tests and I have encounter a problem. In my main app I have the following logic: public static void main() { if (System.isFuture()) { System.debug('Is future'); // ...
3
votes
1answer
756 views

Custom Logging and Future Methods

I have been reading up on the custom logging, DML, and exceptions but haven't seen anything that talks about @Future methods and exceptions. I have two scenarios: A Button is clicked on a Lead, ...

1
2
3 4 5
9