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

Forums / Developing with Sitefinity / Entries from Forms

Entries from Forms

7 posts, 0 answered
  1. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    23 May 2011
    Link to this post
    I am wanting to create a custom control that displays collective results of the entries from a specific form built in the Forms Module.  Do you have an example of how to retrieve this data?  I have found the FormManager and FormsManager, but I do not see a method that gets entries for a specific form.

    Thanks!
    Alex Lorenz
    Indianapolis Motor Speedway | INDYCAR
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    24 May 2011
    Link to this post
    Hi Alex,

    To get the response of a form you can use

    public IEnumerable GetFormEntries(Type entryType, string filter, string orderBy, int skip, int take, ref int? count)

                var formsManager = FormsManager.GetManager();
                stringentryTypeName = String.Format("{0}.{1}", "
    Telerik.Sitefinity.DynamicTypes.Model", "yourformname");
                var itemType = formsManager.GetEntryType(entryTypeName);
      
                int? totalCount = 0;
                IEnumerable items = null;
                try
                {
                    items = formsManager.GetFormEntries(itemType, string.Empty, string.Empty, 0, 0, reftotalCount);
                }


    Regards,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    01 Jun 2011
    Link to this post
    This gets the entries, but is there then a method to get the values from that entry?

    Thanks!
    Alex Lorenz
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Jun 2011
    Link to this post
    Hi Alex,

    GetFormEntries returns list of the FormEntry which you can use to get the values.

    Regards,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  5. Alex
    Alex avatar
    39 posts
    Registered:
    19 Jul 2010
    15 Jun 2011
    Link to this post
    I am able to get values of the entry, such as SubmittedOn, UserID, IpAddress, but is there another method to get the actual response.  For example, we have a form out there that has a single multiple choice form widget and I want all the values from that single multiple choice question.  Am I missing something to get actual form question data from the custom table that is built on the fly?

    Here is the code I am using, including what you provided:

    var formsManager = FormsManager.GetManager();
    string entryTypeName = String.Format("{0}.{1}", "Telerik.Sitefinity.DynamicTypes.Model", "sf_motegireplacementpoll");
    var itemType = formsManager.GetEntryType(entryTypeName);
     
    int? totalCount = 0;
    IEnumerable items = null;
    try
    {
        items = formsManager.GetFormEntries(itemType, string.Empty, string.Empty, 0, 0, ref totalCount);
         
        foreach (FormEntry item in items)
        {
            //var entry = formsManager.GetFormEntry(entryTypeName, item.Id);
            this.results.Text += item.UserId;
        }
    }
    catch { }
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Jun 2011
    Link to this post
    Hi Alex,

    The code should return all fields. Please take a look at attached short video. Here is the code that was used during the video

    void button1_Click(object sender, EventArgs e)
          {
              var formsManager = FormsManager.GetManager();
              string entryTypeName = String.Format("{0}.{1}", "Telerik.Sitefinity.DynamicTypes.Model", "sf_yourformname");
              var itemType = formsManager.GetEntryType(entryTypeName);
     
              int? totalCount = 0;
              IEnumerable items = null;
              try
              {
                  items = formsManager.GetFormEntries(itemType, null, "Title ASC", 0, 100, ref totalCount);
              }
     
              catch
              {
     
              }
          }


    Greetings,
    Ivan Dimitrov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  7. Anup
    Anup avatar
    3 posts
    Registered:
    24 Jun 2014
    20 Jan 2015
    Link to this post
                MyResumesList model = new MyResumesList();
                //model.MyResumes = GetResumes();
                User user = userManager.GetUser(System.Web.HttpContext.Current.User.Identity.Name);
                List<MyResumesListModel> objMyResumesList = new List<MyResumesListModel>();
             
                //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).Where(x => x.UserId==user.Id).ToList();

                // Loop through all the response records for this form
                foreach (FormEntry record in records)
                {
                    //Use GetValue() to obtain the Field value
                    var FileName = record.GetValue("FileName");
                    var DateUpdated = record.GetValue("DateUpdated");
                    var Id = record.GetValue("Id");
                    objMyResumesList.Add(new MyResumesListModel { ResumeTitle = FileName.ToString(), DateUpdated = DateUpdated.ToString(), Id = Id.ToString() });
                }

                return View("Default", objMyResumesList);

7 posts, 0 answered