Try Now
More in this section
Blogs RSS feed

What happens to Form Builder data when forms are modified?

by Gabe Sumner

In my last blog post, I introduced some of the under-the-hood features that are powering Sitefinity 4.0’s new Form Builder.  Because Sitefinity is powered by Telerik’s OpenAccess ORM, we are able to generate (at runtime!) dedicated tables for these new custom forms. 

Custom table resulting from creating a new form using Sitefintiy 4.0's form builder

The benefits of this behavior were explained in my last blog post.  However, this behavior also raises some concerns.  Specifically, what happens to these tables when Sitefinity forms get modified?  Even more importantly, what happens to the data these tables contain?

Step 1 - Create a Form

To demonstrate this scenario, I’ll create the following quick form:

Creating a brand new form using Sitefinity 4.0's form builder

Then add a handful of form elements (name, job title, company, email address, message).

Sample contact form in Sitefinity 4.0's form builder

After clicking Publish, Sitefinity creates a new table dedicated to storing responses to this form.

Custom table that is created for new Sitefinity forms

[ Hint: I’m viewing this table in Visual Studio using the Server Explorer.  SQL Server Management Studio could also be used to view database table definitions and data. ]

Step 2 – Create some sample responses

The form is now created and can be dropped onto any Sitefinity page. 

Sample Sitefinity contact form on SitefinityWatch

Any responses to this form can then be viewed through Sitefinity’s UI:

Responses to the the Sitefintiy Form Builder form

But these responses can also be seen in the custom table:

8-24-2010 2-38-21 PM

Step 3 – Modify the form

Everything is working as expected.  However, what happens to this data if the form is modified? 

We can test this by removing the Company & Job Title fields and adding a Website field.

Modified form in Sitefinity 4.0's Form Builder

Publish and look at the resulting table modifications:

Modified form table

Because the default column names aren’t terribly descriptive (hint: you can control these column names) it’s hard to see what happened.  Sitefinity added 1 new column (form_text_box__c006), but kept the 2 columns for the removed text fields. 

Submitting a new response for this modified form results in the following data:

Viewing form responses in the custom form table

None of the old data has been lost.  However, new form submissions will result in a NULL value for these orphaned columns.  Furthermore, the old data is not visible within Sitefinity’s UI:

Viewing form responses in Sitefinity 4.0

Step 4 – Rescuing orphaned data

As demonstrated, data is protected during form modifications.  However, by removing the form elements you are disconnecting Sitefinity from the data in these columns.  It will be impossible (as of this writing) to view this orphaned data inside Sitefinity.

To re-expose this lost data inside Sitefinity you need to re-add the form fields that were removed from the form.  This means re-adding form fields of the same type (text box, drop-down, multiple-choice, etc.) and the same ID.

In the example above, I can use the table column names to see the old ID’s of these missing form elements:

  • form_text_box__c003 = Job Title
  • form_text_box__c004 = Company

Armed with this information I can add 2 new text fields to my form:

Re-adding form fields for the disconnected form data

However, I also need to explicitly set the ID’s for these Textboxes:

Explicitily setting the form field ID for a form element

Now, Publish the form.  The orphaned data has now been rescued:

Missing data is rescued - Now displaying on the form responses page

Some additional questions…

What happens if I change the underlying form element type?

In the examples above I added, removed and then re-added Textboxes.  What if I modified the Textbox to be a Paragraph?  This is possible and Sitefinity will modify the column type from nvarchar(255) to text.  In this scenario, no data will be lost.  However, if the field was then modified back to Textbox the column would get modified back to nvarchar(255).   Because this data type is limited to 255 characters this could result in data being truncated.

How do I permanently & completely remove a form and all its data?

Sitefinity tries very hard to protect your data.  However, this becomes a problem when you want to completely remove a form and start over.  Sitefinity will continue to account for old form fields in the database.  I tried to manually remove the database table, but even then Sitefinity would recreate old form fields.  As of this writing, I don’t have a clear answer to this question.   Creating a unique name for the form, results in a fresh start.

How do I view disconnected data without adding the form elements back to form?

I don’t have a good answer to this.  Sitefinity will not display the data if the form element is missing from the form.  Consequently, the form field MUST be available on the form to view results associated with the form field.  However, as demonstrated above, you can always use a database manager (SQL Server Management Studio, etc.) to view the raw data in the form.  It’s not very user friendly, but it will work in a pinch.


As you can tell, I’m exploring all of this along with all of you.  Feedback, suggestions, etc welcomed!


Leave a comment
  1. Aparna Mar 15, 2011
    How to display the text entered in the grid in site finity project manager
  2. Ace Aug 09, 2011
    Hi, How can I activate the Advanced: Name for developers in order for me to change the exact name of the control like what you have shown above?

    Leave a comment