+ Start a Discussion

Message on Record Question

I have a trigger which I can call after and before insert. I needs to warn or show a message to a user if record inserted fulfills the set of conditions.(I dont want to use addError). How can it be achieved? could not find reference as to how to show custom visual force page, thru pop or redirection(which ever works) .


You can't send the user to another page from a trigger I'm afraid, addError is the only way I know of to send messages back to the user.


Assuming the insert is happenning as a result of a visualforce action, you should be able to test for the error in the action processing, and redirect from there. 


(If you add the error via addError in a trigger, you can test for it via ApexPages.hasMessages or ApexPages.getMessages.)




There is no other way to show message except adderror() method. you can show popup as a visual force page using javascript function.


var url = '/apex/ma4';



Hope this helps.




how can I  call javascirpt call to show pop up alert box  from inside the trigger?





You can't call javascript from a trigger, as triggers have no knowledge of where they were invoked from - UI, dataloader, webservice etc.