Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I would if someone could give me some advice please...
As part of the upcoming GDPR changes my company has imposed a data retention policy of one month meaning that we're not permitted to keep information that's greater than a month old.
On two of the sites (a version 7 and a version 4 build) I'm running Umbraco Contour and I've been asked if a schedule could be created that deletes form entries that are greater than a month old.
So 2 questions really does anyone have any knowledge of programmatically removing form entries and what would be the best way of creating a scheduled task to fire this programmatic solution.
I've created a scheduled task that runs on a server that fires a web page which runs code when loaded but any sort of browser 'issue' (i.e. Internet Explorer didn't shut down properly) causes the schedule task to fail so this solution is unstable for this request really.
Thanks in advance,
I'm not sure if this will help but we run a sql script shown below that clears our form entries from the previous 14 days. The script is run daily via a schedule. You can amend it to do previous 28 days by just changing the 14 to 28 if you need to delete last calendar month then you will need to add some code work that out.
Where Created < GETDATE() -14
Hope that helps
So just to confirm this deletes Contour records from the last 14 days??
If that's the case then that's awesome work!
Yes this is what we are using to clear down our form entries.
That's brilliant thanks for your time
So would this just delete all of the entries?
Delete FROM [dbname].[dbo].[UFRecords]
yes it would
Sorry this is probably a bit late but I needed to do something similar and just found your thread.
Just a heads-up, at least on the instance I've spun up anyway. There's no referential integrity in the db (MS-Sql in my case) between the UFRecords table and the various record value fields UFDataRecordString etc so to truly remove the data you'll also need to clear these tables.
As regards programmatically handling records, you can create a class that derives from ApplicationEventHandler and add an event handler for the RecordStorage events e.g.
public class MyUmbracoApplication:ApplicationEventHandler
protected override void ApplicationInitialized(UmbracoApplicationBase umbracoApplicationBase, ApplicationContext applicationContext)
RecordStorage.RecordInserting += RecordStorage_RecordInserting;
RecordStorage.RecordUpdating += RecordStorage_RecordUpdating;
private void RecordStorage_RecordInserting(object sender, RecordEventArgs e)
// do something here, record is in the RecordEventArg object
private void RecordStorage_RecordUpdating(object sender, RecordEventArgs e)
//do something here
To delete a record you can spin up a new instance of the RecordStorage class like so:
using (var storage = new RecordStorage(ApplicationContext.Current.DatabaseContext))
Just adding for completeness in case anyone else drops by :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted