Confused in using agents to create new documents

Hello everyone, I am not sure if my plan of attack is even correct. I am fairly new to agents. I am creating an Agent (LotusScript), which performs it’s Document Selection through using a Folder (view). The view itself works correctly, but my issues are from there forwards.

General Idea:

For every document in the Selection, I want to examine it’s field values to decide whether or not to silently create a new document. I can create the new document, that is not the issue. The issue is accessing the field values of the documents in the Document Selection.

  • I’ve always relied on using ‘NotesUIWorkspace.CurrentDocument’ for non-agents, and obviously cannot use that now.

  • Using Forumla seems to imply that the field values of the Selection documents are conveniently initialized and readily available, unlike LotusScript.

Would something like ‘NotesView.GetParentDocument’ or NotesDocument.GetDocumentUNID’ be useful here? I’m afraid I am a bit strapped for time and cannot afford to play around to test different angles.

Also, I am an avid user of MS Visual Studio and similar robust IDEs. Domino Designer usually makes me cry. Any suggestions as to how to keep the helpful popup window, with the class/library of methods, from breaking? It always breaks on me, to where it refuses to show up until I close/reopen Designer. Extremely annoying and cumbersome.

Appreciate any help. Thanks all

Subject: for selected documents, use a collection of unprocessed documents

’ here you are getting the value of the subject field on the first document in the selection

Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument()

string$ = doc.Subject(0) 

With regards to your problems with the designer client - I just watched someone using 8.5.1 designer yesterday, and that looks like it would solve your problem, and it is a much nicer solution. (I haven’t had that problem myself.)

Subject: Thanks guys. Got it…

Seemed difficult at first but not so bad once you wrap your head around the process :slight_smile:

Also, I will see of 8.5.1 is available to us. I have 8.0.1 FP

Thanks

Subject: LS agent

The algorithm is always the same:

Dim session As NotesSession

Dim db As NotesDatabase

Dim myView As NotesView

Dim curdoc As NotesDocument

Dim newdoc As NotesDocument

Set session = New NotesSession

Set db=session.CurrentDatabase

Set myView=db.GetView(“BlahView”)

Set curdoc = myView.GetFirstDocument

While Not (doc Is Nothing)

v1=curdoc.MyField1(0)

v2=curdoc.MyField2(0)

    .

    .

’ place your useful code here ex:

If (v1=“dummy”) Then

newdoc = db.CreateDocument

.

.

Call newdoc.Save(True,False)

End If

    .

    .

Set curdoc=myView.GetNextDocument(curdoc)

Wend

Thierry Cayla

http://dominoeffects.serveblog.net