5

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 -


archive 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.

4

No, there are no database events triggered for activation*, deactivation*, and archive events. In fact, there doesn't even appear to be a field that allows you to determine if a product has been archived. (* I'm referring to the Activate and Deactivate links on the product's list view; simply changing the status using inline edit/normal edit still fires database triggers).

1
  • 1
    Cheers @sfdcfox my worst fears are realized then. Time to have a chat with the client. Might stick something on the ideas exchange too. Dec 2 '15 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.