1

The background of the problem is: I am building up a trigger on account which will be triggered when an account is deleted. During execution it will invoke some webservices. But while deleting an account the trigger throws an exception 'System.CalloutException: Callout from triggers are currently not supported'. I think it means that webservices can not be invoked from a trigger.

One possible approach to resovle this issue is using @future annotation for methods invoking webeservice(s). Does any body knows any other solution?

2 Answers 2

2

The execution of outbound-calls is not possible without using @fucture annotation.

As I understand your question you want to call a external system and notify the system that the record was deleted.

A general problem in this case is that your external system might not be available. Therefore you should create a custom object. In this custom object you can store a "delete notification record". (Consider to add a status field)

In a second step you can implement a outbound-notifier class. This class can be called via a @future or a scheduled job. Make sure that you only change the status value of your "custom sync record" in case the transaction was successful.

1
  • 3
    We use a mechanism very similar to this. The custom object represents queued integration calls that are later periodically executed by a scheduled class.
    – sfdcfox
    Aug 26, 2014 at 14:12
1

(Assuming you are not trying to build some logic that retries), you can wrap the existing method calls in methods annotated with @future and so leave the existing methods unchanged:

public class NewClass {
    @future(callout=true)
    public static void invokeWebServiceInFuture1(...) {
        ExistingClass.invokeWebService1(...);
    }
    @future(callout=true)
    public static void invokeWebServiceInFuture2(...) {
        ExistingClass.invokeWebService2(...);
    }
}

There is no way of making web service calls synchronously from triggers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .