I'm trying to create a future method that makes a callout, and for some reason it's not invoked when the script is done.
postInstallScript.cls:
global class postInstallScript implements system.InstallHandler {
global void onInstall(InstallContext ctx) {
// ...
myFutureMethod('test');
}
@future(callout=true)
global static void myFutureMethod(string s) {
// sending email on invoke
}
}
I'm trying to simply send an email as a test once the method is invoked, and it works only when I take off the @future
annotation from the myFutureMethod
method, but as the method contains a callout, it cannot be executed from the onInstall
method, and trows an error:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out