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
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 ...
1
vote
1answer
906 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 ...
6
votes
1answer
8k 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
1k 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? ...
11
votes
1answer
11k 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}', ...
11
votes
3answers
3k 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
1k 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
92 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 ...
8
votes
1answer
3k 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 ...
3
votes
1answer
450 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
881 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 ...
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....
2
votes
1answer
154 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
812 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 ...
17
votes
3answers
5k 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
629 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, ...
21
votes
2answers
832 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 ...
9
votes
4answers
6k views

How far in the future are @future annotated methods executed?

What is the maximum estimated time before execution of an @future annotated method starts, after the call to the function is made? Is this in the order of seconds? Or can it take up to minutes before ...
11
votes
4answers
3k views

How can you avoid hitting 24-hour limits on emails and future calls?

I realize there are plenty of ways to try to avoid hitting limits in the first place, but when it comes to features with 24 hour limit plans, how can you know if you're getting close to them? And ...
13
votes
3answers
1k views

Use JSON serialization to get around parameter limitations for future methods?

Future methods can only take primitives or collections of primitives as parameters. To get around this you could serialize Sobjects (or classes) to a string and then deserialize them in the future ...
2
votes
3answers
1k views

Options for callouts from triggers

I need to make some callouts from code that initiates from a trigger. I realize that you can't do a callout directly from a trigger. Currently what I do is make a future call to code that then ...
25
votes
2answers
8k views

How can I determine how many future calls have been executed in 24 hours?

I just ran into a huge gotcha in Salesforce: the 24 hr limit on # of future calls - cf. http://www.sundoginteractive.com/index.php?/sunblog/posts/governor-limit-gotchas-part-1-the-future-call/. I ...
5
votes
3answers
547 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 ...
2
votes
2answers
2k views

Notify users of errors that occur in a future method

How can I notify users of errors that are encountered within a future method? Outside of a future method I'd usually resort to ApexPages.addMessage(), but this isn't possible without the browser ...
-1
votes
1answer
467 views

What areas/topics should one invest in learning/training? [closed]

I was granted/offered by our CEO that I can take a course (or other training on salesforce). This got me to think: WOW - there are so many fields/areas/topics in Salesforce, and as my knowledge as ...
14
votes
3answers
1k views

Batch Apex in AppExchange package and orgs with related triggers that call @Future methods

Here's the problem: when an org has a trigger that calls an @Future method, any batch Apex that fires that trigger will fail, since you cannot call an @Future method from an @Future method OR from ...