I am using umbraco 7.3.1, i want to customize to delete all old versions of a doctype when publish new one, just tried to use DeleteVersion inside ContentService but after ran, there was no revision get delete.
I tried with both true|false for param "deletePriorVersions".
I bit of an old topic I guess, but this still doesn't seem to work...
We've made an importfunction to update a lot of nodes each day. Because we don't want the database to grow larger and larger, we decided to throw away the versions of the node in each import.
Just by executing this line:
cs.DeleteVersions(nodeId, removeOlderVersionsFromDate.Value, userId);
Where removeOlderVersionsFromDate.Value is DateTime (DateTime.Now.AddDays(-1))
This doesn't seem to do anything at all... Is there another way to get rid of the audit trail for a node?
Is there another way to get rid of the audit trail for a node?
It would be a hack, but you could always directly delete from the database tables. I would also recommend writing up an issue here so you can get rid of the hack at some point: http://issues.umbraco.org/issues
Server error: Contact administrator, see log for full details. The DELETE statement conflicted with the REFERENCE constraint "FK_umbracoDocumentVersion_umbracoContentVersion_id". The conflict occurred in database "DBNAME", table "dbo.umbracoDocumentVersion", column 'id'. The statement has been terminated.
DeleteVersion inside ContentService does not work
Hi all,
I am using umbraco 7.3.1, i want to customize to delete all old versions of a doctype when publish new one, just tried to use DeleteVersion inside ContentService but after ran, there was no revision get delete.
I tried with both true|false for param "deletePriorVersions".
Is there any body can help?
Hi Bean,
can you show us the full code you used?
/Michaël
Hi Michael,
This is a function that i created to update the weather information in our system
public bool UpdateWeatherInfo(int citySettingsId, string temperature, string weatherIcon, string cloudyGusts, string humidity, string wind) { var node = Services.ContentService.GetById(citySettingsId); node.SetValue("temperature", temperature); node.SetValue("weatherIconId", weatherIcon); node.SetValue("cloudyGusts", cloudyGusts); node.SetValue("humidity", humidity); node.SetValue("wind", wind); var currentVersion = node.Version; try { ContentService.SaveAndPublishWithStatus(node); Umbraco.ContentImport.Utils.LoggingHelper.LogInfor("Current version is " + currentVersion.ToString()); ContentService.DeleteVersion(citySettingsId, currentVersion, true); return true; } catch { }; return false; }
Hi Bean,
if you want to delete all older version maybe you could use the function
.DeleteVersions(int id, DateTime versionDate, [int userId = 0])
Then for the date you take the current date when adding a new version.
This will remove all version to till current date.
Hope this helps
/Michaël
Hi Michael,
I also tried with
ContentService.DeleteVersions(1234, DateTime.Now.AddDays(-100));
but it runs forever although it only has 12000 versionsWhat's wrong here?
Hi Bean,
you have 12000 versions that needs to be deleted? WOW!
So if you run this function it keeps running untill you get an error or did you manually stop it after a period of time?
Can you check the log under
App_Data/logs
to see if anything is logged there?/Michaël
Hi,
I bit of an old topic I guess, but this still doesn't seem to work...
We've made an importfunction to update a lot of nodes each day. Because we don't want the database to grow larger and larger, we decided to throw away the versions of the node in each import.
Just by executing this line: cs.DeleteVersions(nodeId, removeOlderVersionsFromDate.Value, userId);
Where removeOlderVersionsFromDate.Value is DateTime (DateTime.Now.AddDays(-1))
This doesn't seem to do anything at all... Is there another way to get rid of the audit trail for a node?
It would be a hack, but you could always directly delete from the database tables. I would also recommend writing up an issue here so you can get rid of the hack at some point: http://issues.umbraco.org/issues
Hello,
version 8.0.2
on content save to prevent saving huge amount of version in time I do call
getting
is working on a reply...