Search code examples
c#.netektron

Use Ektron API to conect an event to fire on smartform submit


I have an Ektron smart form on a masterpage. I want to call some custom C# code upon submission of a specific smart form.

Is this possible? is there an other way of doing it?

or indeed a way to setup a listener when smart form entry is added to the table.


Solution

  • After some investigation - the best way forward for this seems to be to use a 'strategy'

    add this to the ObjectFactory.config

    <add name="Form">
          <strategies>
            <add name="SmartFormStrategy" type="MyNamespace.SmartFormStrategy" />
          </strategies>
    </add>
    

    then a new class along these lines

     public class SmartFormStrategy : FormStrategy
            {
                public override void OnAfterSubmit(FormData formData, FormSubmittedData submittedFormData, string formXml,
                    CmsEventArgs eventArgs)
                {
                    var formFieldDataItem = submittedFormData.DataItems.ToList().FirstOrDefault(x => x.FieldName == "EktFormId");
    
    //act upon the form submit results
                  }
        }