Issue with desing of Copying Group document from one DB to another DB

Hello All,

I am writing a Lotus Script which can copy all the groups from source NAB on source server to the destination NAB on destinations server.

I have put my lotus script which does it below.

This script is working fine, but I have a design problem in this:

Assume I schedule this script on domino server which will keep copying the groups, who will take care of presence of groups on the destination db/server. Do i have to do a check for this in my script or i can straight away copy it.

I mean to ask is…

a. Assume today I run this script and it copied 3 groups from source db on source server to dest. db on dest. server.

b. Now assume on the next day this script runs again, and assume that there are no new groups on source db, then will it copying create duplicate groups on dest. db on dest. server.

What is happening now is when I run the script for the ffirst time all is working fine.

If I run it for second time, the groups gets duplicated and If I run the same script again, I see 3 sets of same group.

I need to solve this issue. If I keep doing a search for each document i copy in the destination NAB, it going to be a BIG perfomrmance issue. There are more than 2500 groups in the setup on which I am running this script. I want to schedule this script as a Lotus Notes Agent, so that the groups updations can be synchronized with the dest. db on dest. server.

'=========================================================================================================================

Sub Initialize

Dim session1 As New NotesSession

Dim sourcedb As NotesDatabase

Dim sourceView As NotesView

Dim docSource As NotesDocument

Dim session2 As New NotesSession 'Used two session objects because the dest. db is on different server, but this script is written using one server 'only.

Dim destdb As NotesDatabase

Dim docDest As NotesDocument

Set sourcedb = session1.GetDatabase(“SSPDV370/SP/SD_DV”, “names.nsf”) 'DEV

If Not sourcedb.IsOpen Then

Print "IDMS Agent Error : Database names.nsf not found on SSPDV370/SP/SD_DV server" + Now 

End If

Set destdb = session2.GetDatabase(“SSPDV370/SP/SD_DV”, “studentgroups.nsf”) 'This server could be different, for testing I have kept it same.

If Not destdb.IsOpen Then

Print "IDMS Agent Error : Database studentgroups.nsf not found on SSPDV370/SP/SD_DV server" + Now 

Else

'Copy Internal Groups 

Set sourceView = sourcedb.getView("SPAutoGroups - A") 

If sourceView Is Nothing Then 

	Print "IDMS Agent Error : No group documents found in the names.nsf" 

Else 

	Set docSource = sourceView.GetFirstDocument 

	While Not docSource Is Nothing 

		Set docDest = New NotesDocument(destdb) 

		Call docSource.CopyAllItems(docDest, True)

		Call docDest.Save( True, True) 

		Set docSource = sourceView.GetNextDocument(docSource) 

	Wend 

End If 

End If

Exit Sub

'=========================================================================================================================

Any help would be greatly appretiated

thanks

SR

Subject: Issue with desing of Copying Group document from one DB to another DB

Sunil,

If you don’t want to make any lookup for each doc in the Target db, better create a view and store only the docs which needs to be copied and once doc get processed set some flag in that doc through your agent, so that doc will not be available in that view. It will solve your purpose.

chk from the 6th line …

Set docSource = sourceView.GetFirstDocument

While Not docSource Is Nothing

Set docDest = New NotesDocument(destdb)

Call docSource.CopyAllItems(docDest, True)

Call docDest.Save( True, True)

docSource.processed =“Yes”

Call docSource.Save( True, True)

Set docSource = sourceView.GetFirstDocument

Wend

In the view you need to store only the docs having ‘processed’ value is blank.

Thanks,

Saswat

Subject: Also remember to handle Groups deleted or renamed at the source

Subject: RE: Issue with desing of Copying Group document from one DB to another DB

This doesn’t take into account the scenario where is copied from Server A to Server B one night, then the same group is modified the next day. When the agent runs on the subsequent evening, the flag would have been set and it would not be copied a second time.

Or maybe I missed something?

Subject: RE: Issue with desing of Copying Group document from one DB to another DB

if you’re running your script once per day, every day your best bet would be to do a collection in your script that checks the LastModified property of the doc and only copy it if the modifed date is greater than the agent’s last run time.