You need to sign in to do that
Don't have an account?
neeedhelp
@future catch exception should be displayed in Vf Page
My code is
public pagereference save(){ //some code for(integer i=0;i<10;i++){ futureprocess(strl,i); } return null; } @future(callout=true) public static void futureProcess(integer i,list<string> strlist){ try{ //some code }catch(exception e){ if(apexpages.currentpage()!=null){ //this condition never satisfies ApexPages.Message errMsg = new ApexPages.Message(ApexPages.severity.ERROR, e.getMessage()); ApexPages.addMessage(errMsg); } } }
In catch block the condition never sets to true and hence unable to display the Error Message.Any Ideas on this
@future executes asynchronously, so isn't tied to any Visualforce page that may have queued it for execution.
The way I've handled this in the past is to have the @future method write its result into a custom object or custom setting, and have the page poll until a value appears which it then displays.
Thanks for your Reply Bob
Here their is one more problem.If I remove this
whenever enter into the catch block Ill be getting an error saying that system.FinalException:ApexPages.addMessage can only be called from a Visualforce page
Can you post an example on this so that it can be more helpful.
Thanks in advance
I can't post an example I'm afraid - this was for a customer and they own the code.
I understand that, but I don't have access to the code any more as it belongs to the customer. I'd have to code up the example from scratch, and I don't have time to do that I'm afraid.