Query forms

Find a form

To find a specific form, you use the FormsManager class and LINQ queries. The following code finds a form with the specified formIdthrough the Native API.

C#
using System;
using System.Linq;
using Telerik.Sitefinity.Forms.Model;
using Telerik.Sitefinity.Modules.Forms;

namespace SitefinityWebApp
{
    public class QueryForms_FindForm
    {
        private FormDescription FindForm(Guid formId)
        {
            var formManager = FormsManager.GetManager();
            return formManager.GetForms().Where(f => f.Id == formId).SingleOrDefault();
        }
    }
}

First, you initialize the FormsManager. Then, you must call GetForms to retrieve all forms and, finally, you filter the lists based on the Idproperty.

NOTE: You can filter by any of the form's properties.

Retrieving all forms

To retrieve all created forms, you use the FormsManager class:

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

namespace SitefinityWebApp
{
    public class QueryForms_GetAllForms
    {
        private List<FormDescription> GetAllForms()
        {
            var formManager = FormsManager.GetManager();
            return formManager.GetForms().ToList<FormDescription>();
        }
    }
}

First, you initialize the FormsManager. Then, you must call GetForms to retrieve all forms and, finally, you convert to list.

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.
This Article Contains
New to Sitefinity?