0
votes

I asked a question ( Lotus Notes 7 - copy / move docs. ( parent & response docs ) without changing the UNID ? ) and I received an answer which helped me a lot! Thanks Knut Hermann!

It works OK, it is an agent working on selecting documents. I was wondering if it's possible to create a schedule agent which runs one time per day? That means the user shouldn't manually selecting the documents and run the agent.

Thank you for your time and for your sharing info!

1
I would be really careful copying documents to another database and changing the UNID if you don't know excatly what you are doing. I started at my current workplace, they had an "archive" agent that copied documents to an archive database and modified the UNID as you want. That came back to bite us pretty bad, and I had to rewrite the code from scratch. There really should not be a need to do what you describe. Why don't you explain what it is you want to actually do?Karl-Henry Martinsson
Hello, Karl-Henry! There is a big .nsf application that we want to decompose into 'little' applications. ( into parts ) The main app has already some docs ( parent & response docs.) and we want to import them into the new ( little ) application. If I just copy and paste it the docs. doesn't have the UNID that paste them together.Florin M.
It is not hard to write an agent that copy the main document and all responses and response-to-responses over to the new database and then re-establish the parent-child relationship. I wrote an archive agent just a few weeks ago, doing exactly that. Simply copy the main document over, then call a recursive function on all the responses, where you use the MakeResponse() method of the NotesDocument class.Karl-Henry Martinsson

1 Answers

1
votes

Yes, you can. Look here. You can set schedule in agent's properties:

enter image description here

You can select which documents will be selected. In example will be all database's documents selected. If you select "None" it's up to you to select your documents in agents's code in a e.g. NotesDocumentCollection.

For your case the easiest will be to select all documents and add an if statement to test if document is not yet in target database:

Set docSource = col.Getfirstdocument()
While Not docSource Is Nothing
    If docTarget.GetDocumentByUNID(docSource.UniversalID) Is Nothing then
        Set docTarget = dbTarget.Createdocument()
        Call docSource.Copyallitems(docTarget, True)
        docTarget.UniversalID = docSource.UniversalID
        Call docTarget.save(True, False)
        Set docSource = col.Getnextdocument(docSource)
    End If 
Wend