I have a requirement to stop products with certain attributes from being archived in Salesforce. Is there anyway to hook into this event happening?
Obviously I tried triggers, but a trigger conditioned to fire as follows does not fire at all during the archiving process..
trigger DeleteProduct on Product2 (
before insert, before update, before delete,
after insert, after update, after delete,
after undelete)
{
// loads of debug
}
So no obvious event is occuring.
That trigger does debug when I am creating, editing and deleting products, but when you click "Delete" on a product that is associated with an opportunity and you get the "You can't delete this, do you want to de-activate or archive it instead" page -
the trigger does not fire in the process of loading that page, or indeed when you click to confirm the archive, no update, no delete.
Is there anything that happens when you archive a product? Does it insert another record perhaps, or update something else that I can trigger off?
I have to achieve this on PricebookEntries too and I'm even more scared of that as they can't even have triggers, so I'm almost hoping there is some other event to monitor (and interrupt) archiving.