+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Reading properties of a filled out form via IFormEntryCreatedEvent

Reading properties of a filled out form via IFormEntryCreatedEvent

4 posts, 0 answered
  1. Elan
    Elan avatar
    5 posts
    Registered:
    16 Oct 2014
    26 May 2015
    Link to this post

    Hi,

    I've inherited from FormsControl and have created custom properties on the object. The form has been deployed to a page.

    I am looking to configure my subclass of FormsControl to have some data about how to process the form data.

    I am subscribing to the IFormEntryCreatedEvent event and would like to read properties that were set on the form when it was dropped on a page.

    I can't seem to find a way to get at the properties of the widget that the submission came from. 

    Perhaps there is a better way to do this?

    ​I am looking to send an email to an email address that is provided in a field of the form. I created properties on the FormsControl which are set via the content editor for the FormsControl I created. One of the properties is the name of the field of the form that contains the email address.

     I can trap the event and tell which form the entry came from, however I have no context of the instance of the FormsControl.

  2. Kaloyan
    Kaloyan avatar
    272 posts
    Registered:
    26 Sep 2016
    29 May 2015
    Link to this post
    Hi Elan,

    I have provided an answer in the support ticket that you have recently opened. Please check it for more details.

    Regards,
    Kaloyan
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
  3. Keivan Kechmiri
    Keivan Kechmiri avatar
    38 posts
    Registered:
    16 Aug 2009
    17 May in reply to Kaloyan
    Link to this post

    Hi

    I have the exact same question, can you please share the provided solution?

    /Keivan

  4. Sabrie Nedzhip
    Sabrie Nedzhip avatar
    534 posts
    Registered:
    26 Sep 2016
    19 May
    Link to this post
    Hello Keivan,

    I am pasting the reply provided in the support ticket:

    Such kind of implementation will not be very simple and might require a lot of customizations. What you can try is to gather the desired information by using the form events from the EventHub:

    AJAX forms events: http://docs.sitefinity.com/for-developers-ajax-forms-events

    Here is a short sample:

    protected void Application_Start(object sender, EventArgs e)
           {
               Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(this.Bootstrapper_Initialized);       
           }
       
           private void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
           {
               if (e.CommandName == "RegisterRoutes")
               {
                   EventHub.Subscribe<FormSavedEvent>(evt => FormEventHandler(evt));
               }
           }
       
           protected virtual void FormEventHandler(FormSavedEvent evt)
           {
               var formTitle = evt.FormTitle;
               var controls = evt.Controls;
       
               Dictionary<string, string> values = new Dictionary<string, string>();
               foreach (var control in controls)
               {
                   var value = control.Value != null ? control.Value.ToString() : null;
                   var fieldName = control.FieldName;
                   values.Add(fieldName, value);
               }
           }

    In addition to this, you may also check the below KB article for more details about getting form field values from form responses:

    http://docs.sitefinity.com/for-developers-get-formfield-values-from-submitted-form-responses

    Regards,
    Sabrie Nedzhip
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
4 posts, 0 answered