rhythmagency / formulate

An advanced form builder for Umbraco.
MIT License
92 stars 50 forks source link

"Export to CSV" breaks if a form is submitted after the hosted page node is unpublished (Umbraco v7.15) #163

Open TFAstudio opened 4 years ago

TFAstudio commented 4 years ago

If you load a web page with a form and that node is then unpublished whilst you still have it open, the form can still be submitted. The experience for the user is adequate as they see the thank-you message and the record is passed to the data handlers without an issue.

However, we have discovered the record is saved to the database with two NULL references:

When we try to export via the back office using the Formulate > Submissions > Export to CSV feature, it fails.

"System.NullRefereceException"
<StackTrace>
at CsvHelper.CsvWriter.WriteField[T](T field) at formulate.app.Controllers.StoredDataDownloadController.GenerateCsvOfFormSubmissions(Form form) at formulate.app.Controllers.StoredDataDownloadController.DownloadCsvExport(GetCsvExportRequest request) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescripto....

The NULL references in the JSON data are the cause.

Valid record:

97986    123DBBD2-BCFA-410E-AFFE-20D6BC216aaa         2019-11-25 01:04:41.447               CFC1A6B7-B65C-4499-8CDF-E77BA550Eccc   [
  {
    "FieldId": "c81939123bae452b9e75de0530cc1bbb",
    "FieldName": "Referral",
    "Value": "Official Website"
  }
]              []             /applications/          1335

Breaking record:

97987    3DD3A390-3E22-428D-B223-D2FFBAF5Dyyy         2019-11-25 01:04:29.370               CFC1A6B7-B65C-4499-8CDF-E77BA550Eccc   [
  {
    "FieldId": "c81939123bae452b9e75de0530cc1bbb",
    "FieldName": "Referral",
    "Value": "Friend is staff"
  }
]              []             NULL     NULL
Nicholas-Westby commented 4 years ago

Thanks for this detailed report.

I have a few priorities ahead of this, but when I get to this I'll make sure to have the export work with null values.

If you would like to submit a PR, that would also be welcome.