+ Start a Discussion
Ajay XiaoAjay Xiao 

Future methods and interfaces

Hi all,
I created an interface, in which the classes that implement this interface has future methods for calling external web services. For some reason it seems that Apex is not recognizing the @future(callout = true) argument and give me the error: callouts from triggers are not supported (the methods are being invoked by a trigger). Things work fine once I remove the implementation of the interface from the class. I attached code snippets for each Apex class/trigger below:The interface I haveAn example class that implements the interface, the addUser is a future method that calls an external service, and it is being invoke by a trigger.The trigger that invoke the class's method using reflection. 
I'll be extremely thankful if someone could help!
Rajesh3699Rajesh3699
Hi Ajay,

You are calling the methd "addUser"  from the instance of a interface but not from the actual class name where the method is decalred as future.

ie, v.addUser instead use as slackIdentifyManagement.addUser(a.Id);

Hope it helps,

Thank You,
Rajesh Adiga P.
LinkedIn : https://www.linkedin.com/in/rajesh-adiga-p-b3611ba7/


 
Ajay XiaoAjay Xiao
Hi Rajesh,

Thank you for your help, that does solve the error by calling the actual class. However, I'm also trying to make the calling in the trigger generic for different classes, that's why I’m using the Type, which requires an interface to be instantiated, is there any way to achieve the same "reflection" with out using the instace of the genral interface?

Thank you!