I’m writing an agent. I have a handle to a backend doc that has been softdeleted. Is is possible, using LotusScript, to restore/undelete it?
Subject: SOLUTION: Is there LotusScript undelete (restore document) method?
I found a solution. While it is true there is no lotusScript command to undelete, you can nevertheless perform the same tasks.I’m doing this via the web too
Within the view, I have alongside each doc in the trash, an undelete icon. Within the URL for each is the agent’s name and the doc’s unid passed as paramenter.
I get the backend doc via a hidden view using getdocumentbyKey because you can’t get a deleted doc with getdocumentbyunid.
Once you have a handle to it, you create a new backenddoc, then copy each item (copyallitems doesn’t work with deleted docs) then save it… then last thing is permanently delete the deleted doc. The end user sees it gone from trash and they see it within the inbox… so it’s just like undelete!
Here is a sample agent that does it:
Dim s As NotesSession
Set s = New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim deleteddoc As NotesDocument
Dim item As NotesItem
Dim unid As String
Set db = s.CurrentDatabase
Set doc = s.DocumentContext
unid = Right(doc.Query_String(0),32)
Dim view As NotesView
Set view = db.GetView( “unidtrash” )
Set deleteddoc = view.getdocumentbyKey(unid)
If Not (deleteddoc Is Nothing) Then
Set newdoc = New NotesDocument( db )
Set item = deleteddoc.GetFirstItem( “Body” )
Call newdoc.CopyItem( item, “Body” )
Set item = deleteddoc.GetFirstItem( “Subject” )
Call newdoc.CopyItem( item, “Subject” )
Set item = deleteddoc.GetFirstItem( “Form” )
Call newdoc.CopyItem( item, “Form” )
Set item = deleteddoc.GetFirstItem( “SendTo” )
Call newdoc.CopyItem( item, “SendTo” )
Call deleteddoc.CopyAllItems( newdoc )
Set item = deleteddoc.GetFirstItem( “From” )
Call newdoc.CopyItem( item, “From” )
Call newdoc.Save(True, True)
Call newdoc.PutInFolder( “inbox” )
Call deleteddoc.RemovePermanently(True)
unid = newdoc.UniversalID
Print ||
End If
Subject: RE: SOLUTION: Is there LotusScript undelete (restore document) method?
Easy way to do it with LS:vDelete = Evaluate({@UndeleteDocument}, docToRestore)
Subject: Is there LotusScript undelete (restore document) method?
Couldn’t find anything about the ls equivalent if there’s one, but there’s this formula language function you can use: @UndeleteDocument