Hi all,
I have enabled version tracking on documents
Is it possible to do a workflow running that will retain only the 5 latest versions of the document?
If yes, can I please have an example of such versions?
Thanks to advise.
Kind Regards,
Sheila
Hi all,
I have enabled version tracking on documents
Is it possible to do a workflow running that will retain only the 5 latest versions of the document?
If yes, can I please have an example of such versions?
Thanks to advise.
Kind Regards,
Sheila
Hi Sheila,
There are no explicit activities within Workflow that will delete document versions, but a possible example of how to build a workflow to retain the latest 5 versions can be found here:
https://answers.laserfiche.com/questions/54553/Delete-document-version
In addition you could use an SDK script to delete the actual document versions as well. It is accessible through the first link or directly here:
http://answers.laserfiche.com/questions/49500/Enable-Tracking--Issue-with-Workflow
Thanks,
Kevin
Sheila,
I needed something similar so I modified Jacob's SDK script a bit. You will want to replace the for loop that looks like this:
for (int i = 0; i < history.Count; ++i)
{
DocumentVersion version = history[i];
// replace "Workflow" with your Workflow User
if (version.Creator == "Workflow")
{
// write an appropriate note for why this version is being deleted
version.Delete("This version was deleted because it was created as part of a workflow.");
}
}
With something that looks like this:
for (int i = 0; i < history.Count -5; ++i)
{
DocumentVersion version = history[i];
//Previously deleted versions have Comment = Deleted
if (version.Comment != "Deleted")
{
//Set Comment = Deleted and delete version
version.Delete("Deleted");
}
}
Just make sure if you edit the delete comment to also edit it in the IF statement.