function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vimal Bhavsar 6Vimal Bhavsar 6 

Future Method for String

Can i write my apex class like this ?

@future (callout=true)

WebService static string SendEmailNotification(string symbol)
{

Code of Logic
return String;

}

Actly i found that @future method can write with void but in my function i want to return string that can't be possible with VOID methos.
so can any one suggest me how can i do this ?


 

bob_buzzardbob_buzzard
Future methods can't return a value as you don't have the concept of any code that invokes the method.  When you execute a metho annotated with @future, this is placed onto a queue for asynchronous execution and your code continues to completion.  Some time later the future method is picked off the queue by the platform and executed.   At that point you have no code that is in a position to receive the response and process it.  The best you'll be able to do is store the result somewhere (custom setting/object) and have some of your code access the result when it needs to.