WFFM and CMS-Only mode in Sitecore 8.1

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).

2d207b2847b4dc82181a07091c296016

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

  1. 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.
  2. 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.

  3. 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:

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?

68349444

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!

  One thought on “WFFM and CMS-Only mode in Sitecore 8.1

  1. May 11, 2016 at 4:52 pm

    Very helpful, informative and funny post, Jason! Thank you for sharing this!

    Liked by 1 person

  2. May 12, 2016 at 7:25 am

    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.

    Like

    • May 12, 2016 at 8:30 am

      100% agree with you Keith. It is kinda silly, but there is hope on the horizon when it comes to forms within Sitecore!

      Like

  3. May 13, 2016 at 12:55 pm

    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?

    Like

    • Mike Donahue
      November 10, 2016 at 5:15 pm

      Chris, I have the same error being logged. Did you ever figure this out? Jason, thanks for this post!

      Like

  4. Kamal
    May 14, 2016 at 9:02 am

    Great ,Very Helpful

    Like

  5. May 18, 2016 at 3:55 pm

    Great post,
    It helped me a lot!

    Like

  6. August 19, 2016 at 7:58 am

    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.

    Liked by 1 person

  7. September 1, 2016 at 8:43 pm

    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?

    Like

    • September 1, 2016 at 9:18 pm

      In 8.1, there is no “Save to Database” save action. It saves to the configured database (Mongo or SQL) on every submit.

      Like

      • chandan
        October 7, 2016 at 12:19 pm

        my form data is not getting saved in mongodb .is it issue with mongodb installation process.

        Like

      • chandan
        October 7, 2016 at 12:21 pm

        In wffm sitecore 8.1 update 3,not able to set text and value of the drop list from cutom field of drplist datasource

        Like

  8. September 1, 2016 at 8:56 pm

    Nice Post!

    Like

  9. saurabh
    December 27, 2016 at 1:25 am

    Very helpful post and specially easy to understand. Thank you Jason….:-)

    Like

Leave a comment