3

Some days ago I imported a WSDL into Salesforce and (different of some years ago) it created an Async class (and of course the sync class). So I decided to search on Google how to use this Async class. I've found some articles about that and I implemented this solution for test... For my surprise, the Async class can't be called inside a trigger. Now I'm asking myself and now asking you all: What's difference between of using this Async class and use @future method (and use Sync class)?

5

The Async class is intended to be used in a continuation. See Make Long-Running Callouts from a Visualforce Page

enter image description here

Basically, a continuation will provide a callback mechanism so that when the async callout is complete you can bring the result back to the client.

A @future method won't provide that callback mechanism. It's more fire and forget.

  • But on trigger context (that you can't wait for an awnser), are @future method and Async class equals? – Átila Castro Alves May 1 '16 at 23:45
  • You can only* use the async Continuation classes from a Visualforce context. They don't work anywhere else. Plus a trigger isn't going to wait around for the callback to occur before it can finish. Triggers need to be as fast as possible. – Daniel Ballinger May 1 '16 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.