When Sitecore 8 was released, the default location for form data saved from WFFM moved to MongoDB. If your organization or client was not ready to adopt MongoDB but still wanted to leverage WFFM to save form data, you were forced to either create your own data provider or create custom save actions for each form to save your data to a custom database.
After what I can only presume was a metric ton of customer, partner and community complaints, version 8.1, among other things, restored the ability to save WFFM to SQL if you were running in the newly-minted Experience Management mode (colloquially referred to as CMS-Only mode).
I know, right?!?!
Well, kinda…
The Problem
The problem is that none of the documentation for installing or upgrading to an 8.1-compliant version of WFFM says anything whatsoever about configuring WFFM in 8.1 to save data to SQL. The WFFM installation puts an empty Sitecore_Wffm database in a Data folder in your webroot, but it’s never mentioned. If you’re running Sitecore 8.1 with Xdb.Enabled set to false in Sitecore.Xdb.config, have installed WFFM, created a form and clicked submit, that data goes nowhere. It’s not saved, no errors are reported, nothing. Nada. Pretty sweet, right?
Through what amounts to piecing together a bunch of tribal-knowledge, I discovered how to configure Sitecore to store WFFM data in SQL. There’s a post in the community forum about a portion of this and I believe I saw a blog post mentioning another small piece of the puzzle as well (although, I can’t recall at the moment). So, I figured I’d stitch it all together. For the community. 🙂
The Solution
- First, you need to take the empty Sitecore_Wffm SQL database that was placed in the %webroot%/Data folder and attach it to your SQL Server.
- Next, you must add a new connection string in App_Config/ConnectionStrings.config for this database.
<add name="wfm" connectionString="insert connection string here" />
Yes, the name of this connection string should be wfm. In Sitecore.Forms.config, there is a WFM.ConnectionString setting that specifies the name of the connection string to use. It is wfm out of the box.
**For the record, while this step isn’t in the installation guide for 8.1-compliant versions of WFFM, I have seen it in official documentation somewhere, I just can’t seem to recall where. And if it’s that difficult to find, it’s a problem. - Finally, in Sitecore.WFFM.Dependencies.config, in the /sitecore/wffm/analytics node, there is an element called <formsDataProvider>. By default, this points to the analyticsFormsDataProvider that, according to the comments above it means:
only form’s data from analytics sql and mongo db is involved in reporting (sql) and export (mongo) processes in this case you should be sure that xDb and tracker is on
This should be set to sqlFormsDataProvider.
Now, if you stop here and try to load the Sitecore console, you’ll be greeted with this lovely error:
If you look a little closer at the configuration of the sqlFormsDataProvider in Sitecore.WFFM.Dependencies.config, it ALSO specifies the name of the WFFM connection string rather than reading the WFM.ConnectionString setting from Sitecore.Forms.config. However, it’s wffm. Because, of course. Why not?
Update this connection string name to match what is in Sitecore.Forms.config and you should be golden!
In the pre-MongoDB days, there was a Save to Database save action for WFFM. Because 8.0 saves WFFM data automatically, this is still the case when saving to SQL in CMS-Only mode.
Hope this helps!
Happy Sitecore trails, my friends!
Very helpful, informative and funny post, Jason! Thank you for sharing this!
LikeLiked by 1 person
Great post. I wish you could look at WFFM form post data from within the CMS without downloading the data as an Excel document. Hopefully WFFM adds that back in at some point.
LikeLike
100% agree with you Keith. It is kinda silly, but there is hope on the horizon when it comes to forms within Sitecore!
LikeLike
Jason, great work! The form submits and then i check the DB (no data) and the log…
[WFFM] Form is saving to db
[WFFM] Tracker.Current.Contact is not initialized
[WFFM] Tracker.Current.Interaction is not initialized
[WFFM] Cannot save form data to Db
Could “Tracker” stuff, analytics which we dont have, be causing the data not to save?
LikeLike
Chris, I have the same error being logged. Did you ever figure this out? Jason, thanks for this post!
LikeLike
Great ,Very Helpful
LikeLike
Great post,
It helped me a lot!
LikeLike
I tried this out today, but no data was saved to the sql database. It turns out that in the Sitecore.Xdb.config the setting Xdb.Tracking.Enabled must be set to ‘true’. Took me a while to figure this out. I thought setting Xdb.Enabled to ‘false’ would make it so that the other settings in the config file would be ignored.
LikeLiked by 1 person
Thank you very much Jason! My next query is how to configure Save to database action on submit button?
Is this means we don’t need to configure any action on Submit button on the form?
LikeLike
In 8.1, there is no “Save to Database” save action. It saves to the configured database (Mongo or SQL) on every submit.
LikeLike
my form data is not getting saved in mongodb .is it issue with mongodb installation process.
LikeLike
In wffm sitecore 8.1 update 3,not able to set text and value of the drop list from cutom field of drplist datasource
LikeLike
Nice Post!
LikeLike
Thank you! 🙂
LikeLike
Very helpful post and specially easy to understand. Thank you Jason….:-)
LikeLike
Glad it helped you!
LikeLike