You need to sign in to do that
Don't have an account?
Mohandaas
Action Method: Add Apex Message
In my controller I have an action method that returns a new pagereference. Is there a way I can add an apex message on the landing page?
I tried something like this which is not supported.
public pagereference redirect(){
Apexpages.Message msg = new Apexpages.Message(ApexPages.Severity.ERROR,'Unable to create New Proof of Performance');
Pagereference detail = new Pagereference('/'+program.Id);
detail .addMessage(msg); // not supported
return detail;
}
Has anyone tried this before?
If the controllers of the two pages are not the same, I think the only option that you have is to pass the error message (or an error code etc) as an URL parameter to the target page. Then in the constructor of the controller backing the target page, pull the information from the URL and add the message via the ApexPages.addMessage() mechanism.
Bob,
The controllers are not the same. From a custom controller I am navigating to a SOBJECT standard detail page. I would love to have a message on the detail page.
Ah, that's a different kettle of fish. You may be able to go the route of adding a sidebar component that pulls the error from the URL and puts it into the page via javascript.
Is there still not an easy way of doing this using URL parameters which would populate certain fields/parts of the page being edited? Something like
Not if you are using a standard detail page I'm afraid - there's no way to make the page pull that information from the URL. You could do something along those lines with an edit page, but that would just populate an editable field with the message which wouldn't really make the error jump out at the user.