1

I am trying to create a feature where I can track when a form is archived when Using Umbraco Contour. Typically Umbraco code base has a series of events which I can hook into. However I don't see one here.

The other idea was to have a trigger or something on the database but wanted to see if there was a code only solution to this approach.

Aim Kai
  • 2,934
  • 1
  • 22
  • 34

1 Answers1

1

As far as I know there isn't any specific event that's raised when a form is archived, but you could try subscribing to the FormStorage.FormUpdated event and from there check if the form is archived, then execute your code:

using System;
using umbraco.BusinessLogic;
using Umbraco.Forms.Core;
using Umbraco.Forms.Data.Storage;

public class FormArchiveListener : ApplicationBase
{
    public FormArchiveListener()
    {
        FormStorage.FormUpdated += new EventHandler<FormEventArgs>(FormStorage_FormUpdated);
    }

    void FormStorage_FormUpdated(object sender, FormEventArgs e)
    {
        FormStorage storage = (FormStorage) sender;

        if (e.Form.Archived)
        {
            ...
        }
    }
}
Douglas Ludlow
  • 10,754
  • 6
  • 30
  • 54
  • There, I've had a chance to test it now. Sender is not a `Form`, it is in fact a `FormStorage` object. You can access the current form with the `FormEventArgs`. I've updated my answer. – Douglas Ludlow Jun 25 '12 at 14:27