Thursday, February 15, 2018

Sitecore WFFM programmatic submission does not have data in form reports

I had an instance where I needed to submit a WFFM form (Sitecore 8.2) programatically (as we had user experience requirements that needed it sent via a service call). The form was successfully submitting and in the detailed reports showed this fact:

WFFM detailed reports
However the summary report was empty (as in no graph showing the fields where data was submitted):

WFFM summary report empty
The data export was also showing missing data:

WFFM empty form export
After downloading the export in XML instead of a CSV file, I notice that the field nodes in the XML were showing empty IDs (GUIDs), which meant the fields had not been mapped correctly:

WFFM XML export - empty field IDs
The error was due to the way that I was building up the fields list in the programmatic submission. This was an array of ControlResult objects which represented the form fields. I was originally instantiating the object using the following overload:
public ControlResult(string fieldName, object value, string parameters);
However once I started using the overload that took in field ID, everything started working as expected:
public ControlResult(string fieldId, string fieldName, object value, string parameters, bool secure = false);
Please also see my full example of programmatic submission of WFFM forms in Sitecore 8.2.

No comments:

Post a Comment