You need to sign in to do that
Don't have an account?
Add a message to an sObject via a trigger.
Hola,
I want to add a message to an sObject via a trigger, to provide some visualfeed back to users upon a save of a page.
The standard method addMessage() will not work because it prevents all dml from occuring - something I DONT want to have happen - I still want the record to save.
I also played with the visualforce method ApexPages.addMessage() - but this throws a runtime System.Final exception, because it is not being invoked in the context of a visualforce page.
How can I add a message to the top of a page (be it the red error text, or a PageMessage) with a trigger while still saving the object?
Thanks in advance.
Also - this is a standard page, not a custom visualforce page.
Without a custom visualforce solution, the closest you could come is adding a message field to the object and the page layout. Then using a trigger, update that field as appropriate and make it visible on detail only.
The big drawback is the message will always be stored with the record so everytime one would view the record, the message would be there unless the user edited the record and the edit trigger modified the message.
While that is a good idea, it doesn't provide the same level of visual feedback that a message above the detail sections provides, and doesn't follow the standard error displaying convention used through SFDC. Thanks for the suggestion, though.