I'm trying to export Umbraco Forms data to CSV, in the exact format generated when you export from the Entries table UI, and I'm trying to do this strictly from code. End result is I would like to run as a task to export data daily or every few hours, and save that .csv file to a folder on the server. This would be for bulk importing into other systems, and a Forms Workflow won't work in this case.
My original approach was to try and do this in SQL, but Forms data would be difficult to work with since it's a in a mix of JSON and native SQL data. I'm not running SQL Server 2016 so no JSON support.
I've been searching through the Forms API and found a few things that might help, but can't seem to find what I need. So far I've tried:
Umbraco.Forms.Data.Storage.RecordStorage.GetAllRecords()
This gets the records, but unsure where to get the field names. I don't even see them in the UF
tables. I can generate JSON output via GenerateRecordDataAsJson()
but only get Guids for field names.
I've tried looping through the above Record
collection and manually working with individual items, and I've tried the RecordStorage.BuildRecord()
method hoping that would assemble the data, but no luck there either.