Get FormField values from submitted form responses

You can get the entry values of input fields in a form response.

To do this, follow the procedure:

  1. In the form code-behind, get an instance of the FormsManager class.
  2. Get the form by form name.

NOTE: Unless specified manually, when adding a field to a form, the FormFieldname is automatically generated. To find it, in Sitefinity CMS backend, open your form and perfrom the the following:

>    - For MVC click *Edit field » Advanced » Model » MetaField » FieldName*
>    - For WebForms click *Edit field » Advanced » MetaField » FieldName*
  1. Get the form response entries by form.
  2. For each form response entry, get the value of the form response field by using the GetValue method.

Use the following code sample:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Telerik.Sitefinity.Forms.Model;
using Telerik.Sitefinity.Modules.Forms;
using Telerik.Sitefinity.Model;

namespace Telerik.Sitefinity.Documentation.CodeSnippets.DevGuide.SitefinityEssentials.Modules.Forms
{
   public partial class FormsSnippets
   {
       public static void GetFormFieldValuesFromFormResponses(string formName, string formFieldName)
       {
           FormsManager formsManager = FormsManager.GetManager();

           //Get the Form by Name
           var form = formsManager.GetForms().Where(f => f.Name == formName).SingleOrDefault();

           //Get the FormEntries for that Form
           var records = formsManager.GetFormEntries(form);

           // Loop through all the response records for this form
           foreach (FormEntry record in records)
           {
               //Use GetValue() to obtain the Field value
               var textBoxValue = record.GetValue(formFieldName);
           }
       }
   }
}
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.
New to Sitefinity?