AI agents: the content index is at /llms.txt. Every page is also available as Markdown — send the request header Accept: text/markdown, or append .md to the page URL.
Xperience Docs

Cookie consent

We use necessary cookies (opens in a new tab) to run our website and improve your experience while browsing. Additional cookies are only used with your consent. You may revoke your consent on the Cookies Policy (opens in a new tab) page or in your browser at any time.

Configure (opens in a new tab)
  • Documentation
    InstallationUsing the Xperience interfaceDeveloping websitesConfiguring XperienceManaging usersSecuring websitesDeploying websitesManaging website contentMultilingual websitesMacro expressionsExternal utilitiesIntegrating 3rd party systemsCustom developmentE-commerce featuresOn-line marketing featuresRelease notes - Xperience 13Xperience terminology glossary
  • Tutorial
    Using the Xperience interfaceDeveloper tutorialBusiness tutorialResource hub for marketers
  • API Examples
    ConfigurationContent managementDevelopmentE-commerceOn-line marketingSocial media
  1. Home
  2. Content management
  3. Form data

Form data


Was this page helpful?

Send us feedback Go back to top
  • Community Questions & Answers (opens in a new tab)
  • Contact support (opens in a new tab)

List of examples:

  • Adding data records to a form and sending email notifications
  • Loading data records from a form
  • Updating the data records of a form
  • Deleting form data records

Adding data records to a form and sending email notifications

C#
// Gets the form object representing the 'ContactUs' form on the current site
BizFormInfo formObject = BizFormInfo.Provider.Get("ContactUs", SiteContext.CurrentSiteID);

if (formObject != null)
{
    // Gets the class name of the 'ContactUs' form
    DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID);
    string formClassName = formClass.ClassName;

    // Creates a new data record for the form
    BizFormItem newFormItem = BizFormItem.New(formClassName);

    // Sets the values for the form's fields (UserMessage in this case)
    newFormItem.SetValue("UserMessage", "This is a message submitted through the API.");

    // Saves the new form record into the database
    // Set values for all 'Required' fields in the form before calling the Insert method, otherwise an exception will occur
    newFormItem.Insert();

    // Obtains a factory object used to create a form notification sender service for the given form
    IBizFormMailSenderFactory senderFactory = Service.Resolve<IBizFormMailSenderFactory>();

    // Creates an instance of the form notification sender for the inserted form item
    IBizFormMailSender sender = senderFactory.GetFormMailSender(formObject, newFormItem);

    // Sends a notification email to users (as specified on the form's 'Email notification' tab)
    sender.SendNotificationEmail();

    // Sends a confirmation email to the submitter (based on the form's autoresponder settings)
    sender.SendConfirmationEmail();
}
> Back to list of examples

Loading data records from a form

C#
// Gets the form object representing the 'ContactUs' form on the current site
BizFormInfo formObject = BizFormInfo.Provider.Get("ContactUs", SiteContext.CurrentSiteID);

if (formObject != null)
{
    // Gets the class name of the 'ContactUs' form
    DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID);
    string formClassName = formClass.ClassName;

    // Loads the form's data
    ObjectQuery<BizFormItem> data = BizFormItemProvider.GetItems(formClassName);

    // Loops through the form's data records
    foreach (BizFormItem item in data)
    {
        // Gets the values of the 'UserEmail' and 'UserMessage' text fields for the given data record
        string emailFieldValue = item.GetStringValue("UserEmail", "");
        string messageFieldValue = item.GetStringValue("UserMessage", "");
    }
}
> Back to list of examples

Updating the data records of a form

C#
// Gets the form object representing the 'ContactUs' form on the current site
BizFormInfo formObject = BizFormInfo.Provider.Get("ContactUs", SiteContext.CurrentSiteID);

if (formObject != null)
{
    // Gets the class name of the 'ContactUs' form
    DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID);
    string formClassName = formClass.ClassName;

    // Loads all data records from the form whose 'UserEmail' field ends with the ".net" suffix
    ObjectQuery<BizFormItem> data = BizFormItemProvider.GetItems(formClassName)
                                                            .WhereEndsWith("UserEmail", ".net");

    // Loops through the form's data records
    foreach (BizFormItem item in data)
    {
        // Assigns and saves a value for the form record's 'InternalNote' field
        item.SetValue("InternalNote", "This note was added by the system.");
        item.SubmitChanges(false);
    }
}
> Back to list of examples

Deleting form data records

C#
// Gets the form object representing the 'ContactUs' form on the current site
BizFormInfo formObject = BizFormInfo.Provider.Get("ContactUs", SiteContext.CurrentSiteID);

if (formObject != null)
{
    // Gets the class name of the 'ContactUs' form
    DataClassInfo formClass = DataClassInfoProvider.GetDataClassInfo(formObject.FormClassID);
    string formClassName = formClass.ClassName;

    // Loads all data records from the form that have an empty value in the 'UserMessage' field
    ObjectQuery<BizFormItem> data = BizFormItemProvider.GetItems(formClassName)
                                                            .WhereEmpty("UserMessage");

    // Loops through the form's data records
    foreach (BizFormItem item in data)
    {
        // Deletes all files stored in the form's fields
        BizFormInfoProvider.DeleteBizFormRecordFiles(formClass.ClassFormDefinition, item, SiteContext.CurrentSiteName);

        // Deletes the form record from the database
        item.Delete();
    }
}
> Back to list of examples