+ Start a Discussion
deepakMdeepakM 

how to Show alert message after @future call out?

i have below method

@future (callout =true)
public static void HttpResult(string flightId,string opportunityId) {
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://abc.com/ItineraryBuilder/SendItineraryEmail?frId='+flightId+'&oppid='+opportunityId);
req.setMethod('GET');

try
{
res = http.send(req);
string result = res.getBody();
System.debug('Result' +result);
System.debug('STATUS:'+res.getStatus());
System.debug('STATUS_CODE:'+res.getStatusCode());
if(result == 'Email Sent Successfully' || result.contains('Email Sent Successfully'))
{
//ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Flight Request saved and Itinerary Email sent successfully'));

//want to show alert here
}
else
{
//want to show alert here
}

}
catch(System.CalloutException e)
{
System.debug('Callout error: '+ e);
System.debug(res.toString());
}

}

 

as i used ApexPages.addMessages but it not used here .so is ther any way to show alert .please let me know.

 

Thanks in advance.

bob_buzzardbob_buzzard

You can't do this as the @future request is disconnected from any browser session.  There's a couple of alternatives I can think of:

 

(1) Post a chatter message to the user

(2) Send an email to the user

(3) Create a custom object/setting, add the message to that and write a visualforce page for the sidebar that displays the message\