You need to sign in to do that
Don't have an account?
Pierre Marie Dartus
Send callout onInstall package
Hello,
Is it possible to send an HTTPrequest at package installation ? Every time an Exception is raised : You have uncommitted work pending. Please commit or rollback before calling. My goal is to notify my server that someone installed the package to setup the application.
Here is a code example :
Any Idea ? Thanks !
Pierre-Marie
Is it possible to send an HTTPrequest at package installation ? Every time an Exception is raised : You have uncommitted work pending. Please commit or rollback before calling. My goal is to notify my server that someone installed the package to setup the application.
Here is a code example :
global void onInstall(InstallContext context) { try { Http h = new Http(); String endpoint = 'myURL'; // Send the request HttpRequest req = new HttpRequest(); req.setEndpoint(endpoint); req.setMethod('POST'); req.setbody('MyData'); HttpResponse res = h.send(req); } catch (Exception ex) { Messaging.SingleEmailMessage emailTobeSent = new Messaging.SingleEmailMessage(); list<String> listEmailMembers = new list<String>(); listEmailMembers.add('myEmail@adress.com'); emailTobeSent.setToAddresses(listEmailMembers); emailTobeSent.setSubject('Post install exception'); emailTobeSent.setHtmlBody('Message : ' + ex.getMessage() + 'Line no : ' + ex.getLineNumber() + ' getStackTraceString ' + ex.getStackTraceString() + '' + ex.getCause()); Messaging.SendEmailResult [] r1 = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {emailTobeSent}); } }
Any Idea ? Thanks !
Pierre-Marie
It is mentioned in the documentation that InstallHandler Interface can only perform callouts using an async operation. The callout occurs after the script is run and the install is complete and committed. So, you can call a futher method to perform the callout in post installation script.
All Answers
It is mentioned in the documentation that InstallHandler Interface can only perform callouts using an async operation. The callout occurs after the script is run and the install is complete and committed. So, you can call a futher method to perform the callout in post installation script.
Thanks for the anwser.
Hi,
Am having similar kind of issue, will you please help me out.
Thanks