milium.blogg.se

Formentry to database
Formentry to database











formentry to database

Parameters.Add(new SqlParameter(., (object) this.EndDate)) įrom my earlier trip to the database, I knew that the entry creation date was stored as datetime2(3) format:ĭatetime2 is available since SQL Server 2008 and is a far superior type than its predecessor datetime as it allows for a larger range of values and higher precision.

formentry to database

Parameters.Add(new SqlParameter(., (object) this.StartDate)) Parameters.Add(new SqlParameter(., (object) this.FormDefinitionId)) While rummaging through the .Commands.FormDataDelete class, the SetParameters method piqued my interest: protected override void SetParameters(SqlParameterCollection parameters) So I fired up dotPeek again and dived deeper. for one of the three entries I had in the database. After some head-scratching, I removed one tick from the startDate, and guess what - it worked. I added some logging to check if the date and form ID were correct and it seemed that they were.

#Formentry to database code#

Ran the code again, but nothing was deleted from the database. I used the DateTime.AddTicks method on the endDate parameter to create the smallest possible range. Unfortunately, Sitecore developers were sneakier and I got the following message: EndDate must be after StartDate.īummer. I wanted to be sneaky and used the same date as both the startDate and endDate parameters. I checked the stored procedure using SQL Server Management Studio and saw that the date is compared using greater-or-equal and less-or-equal operators. If you're working on a real project, I would suggest going the first way as it is a much cleaner solution.Īfter processing the data, I called the SqlFormDataProvider.DeleteEntries and hoped for the best. Use the existing method and specify the smallest time range possible to single out the correct entry.īecause I was only working on a proof-of-concept I chose the second option.This is how the SqlFormDataProcider does its magic. Create a custom stored procedure on the ExperienceForms database and write code similar to the FormDataDelete class, which would allow for deleting entries with a given ID.This seems quirky, but it must have been enough for Sitecore. There is no out-of-the-box functionality to remove a form entry by its Id. I was shocked that by default there is only the option to remove either all entries for a given form or remove entries from a given period. Honestly, I was really happy with how easy everything was up until I got to the point where I had to remove the data from the database. The retrieved object is an IEnumerable of FormEntry objects, all of which have the following properties : Retrieving the submitted data was very easy, all that was required of me was the form item's Id. I looked up how Sitecore accomplishes it and stumbled upon the IFormDataProvider interface and its SqlFormDataProvider implementation. This week, I had to do some work on the saved data and remove it from Sitecore if everything goes right in the processing pipeline. The data can then be exported to a CSV file using the Forms dashboard. Sitecore Forms provides out-of-the-box functionality for saving entered data into the ExperienceForms database.













Formentry to database