Document roll back
The button to do the roll back does a save of the document with &rollback=[DocUnid] in the URL. In the QuerySave agent, I check if this value is present. If so, I do the roll back and store a new version.
Roll back?
sRollBackUnid=ds.getQuery("rollback")
If sRollBackUnid>"" Then
doRollBack doc, sOverflow, sRollBackUnid
makeVersion doc, sOverflow
...
The roll back code
The code has three parts:
- Remove all the fields that will be replaced. This is necessary to avoid duplicate fields.
- Copy all the fields from the previous version.
- Update the versioning information.
Sub doRollBack(doc As notesdocument, Byval sDbPath As String, Byval sUnid As String)
On Error Goto catch
Dim s As New notessession
Dim doc2 As NotesDocument
Dim items As Variant
Dim tmpItem As NotesItem
Set db=s.GetDatabase("", sDbPath)
Set doc2=db.GetDocumentByUNID(sUnid)
items=doc2.Items
Forall item In items
Set tmpItem=doc.GetFirstItem(item.name)
While Not tmpItem Is Nothing
tmpItem.Remove
Set tmpItem=doc.GetFirstItem(item.name)
Wend
End Forall
doc2.CopyAllItems doc
doc.Reason="rolled back from version " & Cstr(doc2.version(0))
Goto finally
catch:
Print "Error in doRollBack, " & Err & " in line " & Erl & ": " & Error$
Resume finally
finally:
End Sub
Comments
To add a comment, log in or register as new user. It's free and safe.