benpoole.com

“It is a very sad thing that nowadays there is so little useless information.”

Tip #12: delete a local replica

Written by Ben Poole on 17 Sep 2003
Categories / keywords: Quick tips, Lotusscript
(click on a term to search for related articles at this site)

Add a comment...



The code

Nice and short this one. You just need to edit the constant at the top detailing the replica ID of the file to remove. I typically dump code like this in a button in a mail or whatever. It's a common request in our organisation, so maybe this will be of use to you too.


	Dim db As New NotesDatabase("", "")
	Dim strRepID As String
	Dim strMsg As String
	Dim strTitle As String
	Dim strPath As String

' // Replica ID of file to remove
' // (omit the colon in the middle)
	strRepID = "@@@@@@@@@@@@@@@@"

	Const SUCCESS = "Database successfully removed."
	Const NO_DB = "Halting: Couldn't find database to removed."

	If db.OpenByReplicaID("", strRepID) Then
' // Found Db, so grab its filepath and title
		strPath = db.FilePath
		strTitle = db.Title
		strMsg = "I've located the database to remove ('" &_
		strTitle & "'). Is this OK with you?"

		' // Set to Nothing so we can re-instantiate
		Set db = Nothing

		' // Instantiate once more, this time using
		' // file path derived above
		' // This way we can remove the db; the
		' // previous way we could not
		' // and we needed to use db.ReplicaID
		' // first time around
		Set db = New NotesDatabase("", strPath)
		If db.IsOpen Then
			' // Prompt YES / NO to removal
			If Messagebox(strMsg, 4, "Remove?") = 6 Then
				Call db.Remove()
				Messagebox SUCCESS, 0, "Complete"
				Exit Sub
			End If
		End If
		
	Else
		Messagebox NO_DB, 0, "Complete"
	End If

   » Tip #12: delete a local replica (Ben Poole 17 Sep 2003)
   RE: Tip #12: delete a local replica (jk 22 Jul 2005)

Add a comment...