replied on January 30, 2014
You can use the Laserfiche SDK (via a SDK Script activity) to delete specific versions from the version history of a document. However, you should be aware that doing so will cause your version history to have "gaps" in its version numbers. Also, the current version of a document cannot be deleted, so if Workflow created the most recent version, it would still be listed.
You would use a script similar to the following in your SDK Script activity:
protected override void Execute()
{
if (this.ScriptEntryInfo != null)
{
if (this.ScriptEntryInfo is DocumentInfo)
{
DocumentInfo doc = (DocumentInfo)this.ScriptEntryInfo;
if (doc.IsUnderVersionControl)
{
VersionHistory history = doc.GetVersionHistory();
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.");
}
}
}
else
{
this.WorkflowApi.TrackWarning("The document '{0}' is not version controlled.", doc.Name);
}
}
else
{
this.WorkflowApi.TrackWarning("The entry '{0}' is not a document.", this.ScriptEntryInfo.Name);
}
}
else
{
this.WorkflowApi.TrackWarning("No entry was specified.");
}
}
One other thing to note is that you would still need to determine when you wanted the workflow to run.