You need to sign in to do that
Don't have an account?

Can a Trigger use PageReference or some other way to re-direct the page
Hi All,
I have a trigger that runs to verify an account can be deleted before it is actually deleted. If it can be deleted, that is ok. If the Account cannot be deleted, the trigger changes the Account Owner to a dummy user so the data is not lost but the Account cannot be seen by standard users.
Should the Account Owner change, what I would like is for the trigger to re-direct the user to the Home Page of Salesforce. At present, the user then sees the Account (Account Owner has changed and all) but I would like it to look like the Account has been deleted.
I have tried this with the PageReference class in my trigger but it does not seem to be working.
Any ideas??
Thanks
Warren
Hi,
I am not sure how you could perform a redirect from a trigger. The trigger could be running outside of the context of a page - e.g. loading data via the data loader and attempting to move to a page would not then make sense.
As well as changing the owner on your 'delete' operation, you could also change the record type of the record. If you create a new record type and page layout combo ('deleted record') and displayed minimal information - even a formula field saying something like 'Record has been successfully deleted' would that be better ?
Hope this helps.