1

We have one specific requirement for WFFM. We have one simple HTML form and we need to save its data to WFFM form programatically. So question is that how to create Form object at runtime and get its fields, assign HTML field values to WFFM form fields and insert the WFFM form data to MongoDB.

We are at version 8.1 rev. 151207 (Update-1)

-1

First thing. The implementation of the WFFM 8.0 and later revisions were changed, so later versions were changed according to the the new functionality like storing data in the xDB analytics database and aggregating it to the SQL reporting database.

So here is what you can try to do.

Try to Override “analyticsFormsDataProvider” (the “Sitecore.WFFM.Analytics.Providers.AnalyticsFormsDataProvider” class) which is defined in the “\App_Config\Include\Sitecore.WFFM.Dependencies.config” file.

Create custom form verification action in order to change the field value before form proceeding.

If you want to know more on how to create a form verification action, You can refer to documentation: https://sdn.sitecore.net/upload/sdn5/products/web_forms2/25/web%20forms%20for%20marketers%20v2_5%20reference-a4.pdf and look for How to Create a Form Verification Action.

So action will look like

public class CustomFormVerificationAction : BaseCheckAction
{
    public override void Execute(ID formid, IEnumerable<ControlResult> fields)
    {
       foreach (ControlResult field in fields)
       {
            if (field.FieldName == "NewField")
           {
                string newValue = "htmlvalue";
                field.Value = newvalue
           }
       }
    }
}

In this case, your form verification action will be executed before the “Register a Goal” system action and the changed field value will be saved to xDB. Try and see if this gives enough direction and works for you.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.