Thursday, January 29, 2015

What are @Featuremethod Considerations?

What are @Featuremethod Considerations?

Methods with the future annotation must be static methods, and can only return a void type. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types. Methods with the future annotation cannot take sObjects or objects as arguments.

  • Specify (callout=true) to allow callouts in a future method. 
  • Specify (callout=false) to prevent a method from making callouts.

@future (callout=true)
  public static void doCalloutFromFuture() {
   //Add code to perform callout

  • Remember that any method using the future annotation requires special consideration because the method does not necessarily execute in the same order it is called.
  • Methods with the future annotation cannot be used in Visualforce controllers in either getMethodName or setMethodName methods, nor in the constructor.
  • You cannot call a method annotated with future from a method that also has the future annotation. Nor can you call a trigger from an annotated method that calls another annotated method.
  • The getContent and getContentAsPDFPageReference methods cannot be used in methods with the future annotation.


Post a Comment

| ,