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.

learn more… | top users | synonyms

5
votes
1answer
66 views

How to test @future methods with setup objects and avoid MIXED_DML_OPERATION

I’m in a situation where I have to use a future method to avoid MIXED_DML_OPERATION error. I have a trigger that runs after INSERT on USER and creates a custom object X. They are in 1:1 relation. ...
0
votes
1answer
50 views

Code in a @future method not working

I am trying to write a trigger that will transfer attachments from a Task object to the related Opportunity object from emails & attachments using Salesforce for Outlook. I have the basic trigger ...
2
votes
0answers
25 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: ...
0
votes
1answer
60 views

System.LimitException: Too many future calls: 11 [duplicate]

when i am changing the case owner for more than 10 records in the case list it is throwing the error : Apex trigger LFIQTriggerForCaseChanges caused an unexpected exception, contact your ...
4
votes
1answer
72 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 ...
3
votes
1answer
206 views

Future method cannot be called from a future or batch method, Case Trigger with Salesforce for Social

I get the following inside a Case Trigger when I try to call a future method: System.AsyncException: Future method cannot be called from a future or batch method So far this exception ONLY occurs ...
4
votes
2answers
124 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
94 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. ...
1
vote
0answers
45 views

Making apex callout after sendEmail() in Batch apex

This is related to question, Processing callouts from Batch, but is specific to Emails operations. We are sending contents of email in apex callouts. The content contain merge fields, which is not ...
3
votes
4answers
118 views

Chaining @future methods

Is there any way/workaround at all to call a future method immediately from another future event? If not what's the fastest way to call my future method indirectly? I basically have a 3rd party ...
0
votes
1answer
89 views

Hitting future call limit with Geocoding trigger

This trigger seems to work pretty well for Geocoding accounts... trigger AccountGeocode on Account (after insert, after update) { system.debug('AccountGeocode trigger fired'); ...
5
votes
1answer
97 views

Callout from a future event

I have a managed app that does a callout (REST API POST) on Account save. The managed app is developed by a 3rd party that we have no control of. The callout creates a future event which gets an id ...
1
vote
1answer
66 views

How to deserialize JSON inside @future?

This issue lead after I solved one issue regarding JSON Deserialization.Now I need to extract JSON using @future method.I retrieve the JSON and try to deserialize it, but it said it does not recognize ...
2
votes
0answers
128 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
0answers
73 views

@future and triggers

I want to do a bulk update of records in parallel, but Batch Apex doesn't permit this. I was wondering if the following solution would work: I have an SObject defined that holds a value for the ...
1
vote
1answer
87 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 ...
5
votes
2answers
261 views

Is there any way of confirming that an @future method has been called/queued in a test class?

I have a Controller (FooController) which calls an @future method (bar()) belonging to another class (FooServices). Ideally in my test class for this Controller (FooControllerTest) I only want to ...
2
votes
1answer
1k views

You have uncommitted work pending. Please commit or rollback before calling out

i have written a future method here is source code @future(callout=true) public static void futureDownloadAttachment(Set<ID> documentsID){ List<SpringCM_Attachment__c> logs = ...
3
votes
1answer
476 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 ...
1
vote
1answer
119 views

Asynchronous Calls: Order Of Execution In A Test Method

Imagine the following scenario: Trigger myTrigger on User calls a future method which flags Account records. Then a Batch Job must run to process the records. While testing, I am first inserting ...
0
votes
0answers
55 views

“Chaining” @future calls

How is the chaining of future call achieved in example from Dan Appleman book http://advancedapex.com/samplecode/ ? I am trying to insert 200/220 records and see that only one future is forced. ...
6
votes
1answer
307 views

Future vs batch

I need to make asynch call from trigger. Records are comming (1 or 1000 at once) each minute and I need to process them from trigger asynchronously. As I see limits for future and batch jobs are the ...
3
votes
1answer
121 views

Sending HTTP callout after a Lead record is updated

I have a requirement where I have to send Lead data from Salesforce to TIBCO server once Send_to_CRM__c check box goes from false to true on Lead update. Once updated 2 web-services are suppose to go ...
2
votes
1answer
115 views

How can an object with an ID disapear?

I have an error logging object that stores errors. In most cases, when I call my method to create a new Error Log record, it properly creates and inserts the record. When I call the error logging ...
1
vote
2answers
734 views

Error: System.LimitException: Too many future calls: 11

I am very new to Apex and I am having an issue with a trigger. A little background: I have 16 Lookup fields on the Account object that represent our Account Team Roles. I have a trigger that when ...
0
votes
1answer
394 views

Future of salesforce developer [closed]

I'm planning to switch my career to sales force but a question in my mind that made me ask this question..How will be the growth of sales developers in future?? Also job market?
4
votes
1answer
102 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 ...
2
votes
1answer
162 views

Can a schedule be executed from future method?

One cannot execute a batch from a future annotated method. It is also impossible to have a trigger reacting to changes in future calling a batch. I cannot find if it is possible to execute a schedule ...
4
votes
2answers
2k views

What is the best approach to call a webservice from SFDC?

Objective: When an Account is created in Salesforce I need to call a SAP webservice and create a customer in SAP. What would be best approach? To call the SAP webservice from the Account trigger ...
0
votes
0answers
1k views

Apex Callout Exception: IO Exception: Read timed out

I have Salesforce trigger that triggers either a future method or batch job that does call outs to a SOAP webservice. IF the number of call outs I need to make is one then future method is triggered. ...
2
votes
1answer
536 views

Processing callouts from Batch

I have a tough scenario where a future method should be called from a batch.I came across various articles stating that it is not possible. My scenario is i need to send emails for contacts of account ...
12
votes
3answers
2k views

Calling future method from Batch

I have a requirement where a future method need to be called from batch apex ,I came across various articles stating that a future method could not be called from the batch. Is there any alternate ...
3
votes
1answer
81 views

Null Pointer on system.debug in @future method

Can someone explain the error? I have a trigger that passes a set of Event IDs to an @future clas. Below is the class: public class eventChatterFuture{ @future public static void ...
5
votes
1answer
569 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 ...
1
vote
1answer
305 views

How to create and attach PDF upon approval through standard email approval process

I have a scenario PDF needs to be created and attached the same to custom object upon user approval. Users will approve through email approval process. Challenges: Create a PDF using visualforce ...
4
votes
1answer
2k views

Getting current PageReference from Controller Extension in @future context

I'm attempting to get current pageReference for a VisualForce page (renderAs=pdf) that is being executed in @future context, but at the moment it is just returning a null. So I assume the problem is ...
5
votes
1answer
244 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? ...
8
votes
1answer
2k views

Is it possible to make Remote Action Asynchronous?

I have a Remote action call from my Visualforce Page. Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.PartnerPrimeSubController.calculatePartnerPrimeSub}', ...
9
votes
3answers
806 views

Avoiding use of future calls in triggers?

I have some code I'd like to change in a trigger. The issue is that there is a field that is being updated with a prefix plus the value of a field in the object that is an automatic number. The ...
1
vote
1answer
466 views

Updating a visualforce page with the return value of a future call

I am triggering an API call to an external service in my visualforce page. I want to show the response (for example, success/error messages) of the API call without refreshing the page. What I was ...
3
votes
1answer
75 views

Passing Paramaters from a future class to another class

I am trying to pass some parameters from a future class to the constructor of another class and it is passing nulls values. What is the reason for it? (FYI-The @future class is called from a scheduler ...
7
votes
1answer
609 views

Chaining Scheduled Apex to process callouts every 30 seconds

We wanted to create an outbound message queue system that would process requests individually and in order to any external web service. The frequency that these requests should be processed is ...
2
votes
1answer
274 views

Does a VisualForce page embedded in a page layout have to finish executing before the page will load?

Thanks for reading my question. I am looking to create a trigger on the OpportunityContactRole which is unfortunately not supported (I'm curious as to why, if anybody has insight on that, but that is ...
1
vote
1answer
307 views

@future catch exception should be displayed in Vf Page

My code is public pagereference save(){ //some code for(integer i=0;i<10;i++){ futureprocess(strl,i); } return null; } @future(callout=true) public static void ...
3
votes
1answer
705 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 ...
2
votes
1answer
96 views

Heuristics to decide if to run an operation sychronous or asynchronous

Im our app we recently had to switch many operations from short running synchronous calls to asychronous Batch or future calls. It helps us overcome the many limits but also introduces many other ...
-1
votes
1answer
223 views

@future to reduce number of Soql Queries [closed]

Say Suppose I'm having 150 Records in a Custom object and I will display 100 records in a Vf page.When I select all the records and process then what happens is based on criteria,these fields will ...
12
votes
3answers
1k views

Knowing if a future call is allowed

I'm having an issue where we have some code that can be called anywhere and then it makes an @future call to log a message to an external system. The problem is if this method is called (either ...
3
votes
1answer
533 views

How to prevent inconsistent data when using @future methods in triggers?

Due to certain governor limits in my trigger I refactored it to work asynchronously with @future: public with sharing class CustomObject_TriggerHandler { public static void afterInsert(Map<Id, ...
14
votes
2answers
335 views

@Future at risk for race conditions?

Question If I invoke an @future method from a trigger that is performing a calculation based on data that is being committed in the trigger am I at a risk for a race condition? Background We're ...