Skip to Content

TheBlogReaders.com

Salesforce.com, PHP, MySQL, Javascript, Ajax, Htacces

@Future Order of Execution in Salesforce

Be First!

@Future Order of Execution in Salesforce

if you call a @future method from trigger (before/after insert/update) and the @future method will create a different thread for its execution . Since the @future method is asynchronous process. It will not affect or bother about the execution of the trigger. Once method will call via trigger, it will wait for the resources and once the resource available it start its execution. There is a possibility it will start its execution simultaneously with trigger execution or after completion of trigger execution.

Asynchronous Processing in Force.com http://www.salesforce.com/us/developer/docs/async_processing/salesforce_async_processing.pdf

special consideration when any method using the future annotation:

  • You cannot call a method annotated with future from a method that also has the future annotation
  • The getContent and getContentAsPDFPageReference methods cannot be used in methods with thefuture annotation
  • future calls cannot be made from a batch job
  • future calls cannot be execute certain order and its execute based on the resource availability
  • future calls can execute concurrently
  • future calls have some limits (see the salesforce link).
  • No more than 10 method calls per Apex invocation
  • No more than 200 method calls per Salesforce.com license per 24 hours
  • The parameters specified must be primitive dataypes, arrays of primitive datatypes, or collections of primitive datatypes.
  • Methods with the future annotation cannot take sObjects or objects as arguments.

how to prevent this recursive behavior in future calls:
its possble to prevent this recursive behavior below ways:

1) Create a new field in respective object and update the value in future calls method and check the created field in trigger either the value is updated or not.
2) Use a static variable to store the state of the trigger processing or not (true/false)

 

(995)

Previous
Next

Leave a Reply