Agent - Newly created or modified documents

We run the following agent in our address book on newly created or modified documents.

When a new user is created we store the id file in the address book, this agent then runs on the newly created docuement and sends this id file to a mail in database.

However, this only works if you create the user with a Notes 4 client. If a 5 or 6 client is used the agent does not run. If I run this agent manually on a document that has been created in R5/ R6 it works.

Any ideas???

Sub Initialize

'The purpose of this agent is to run against all newly created documents, take a copy of their id file and mail it to the ID deposit database

Dim session As New NotesSession

Dim thisdb As NotesDatabase

Dim newdocs As NotesDocumentCollection

Dim sourcefile As notesembeddedobject

Dim targetfile As NotesEmbeddedObject

Dim escrowdoc As notesdocument

Dim currentdoc As NotesDocument

Dim idfile As notesitem

Dim filename As String

Dim rtitem As NotesRichTextItem

Dim x As Integer

Dim path As String

path = “/lotusdata/user.id”

'path = “E:\temp\user.id”

Set thisdb = session.CurrentDatabase

Set newdocs = thisdb.UnprocessedDocuments

For x = 1 To newdocs.Count

Set currentdoc = newdocs.GetNthDocument( x )

If currentdoc.hasitem(“$FILE”) Then

Set idfile = currentdoc.GetFirstItem ( “$File” )

fileName = idfile.Values(0)

Set sourcefile = currentdoc.GetAttachment ( fileName )

Set escrowdoc = New notesdocument(thisdb)

Set rtitem = New NotesRichTextItem( escrowdoc, “Body” )

Call sourcefile.extractfile(path)

Set targetfile = rtitem.EmbedObject ( EMBED_ATTACHMENT, “”, path)

Kill path

rtitem.values = " Password Unknown"

escrowdoc.Form = “Memo”

escrowdoc.SendTo = “Escrow Agent”

escrowdoc.Subject = currentdoc.fullname

Call escrowdoc.send(False,“Escrow Agent”)

End If

Call session.UpdateProcessedDoc( currentdoc )

Next

End Sub

Subject: Agent - Newly created or modified documents

Hi

Are you sure it runs on “new or modifed” documents?

Is the signer allowed to run the agent?

regards

Jesper Kiær

http://www.jezzper.com

Subject: RE: Agent - Newly created or modified documents

Yes, the signer of this agent does have the correct access, this is proved by the fact that the agent runs on user documents created in Notes 4

Subject: Security restrictions

Hi

One typical error is to forget to set the "runtime security levvel to “Allow restricted operations”.

since you accessing the file system.

Have you done that?

regards

Jesper Kiær

http://www.jezzper.com

Subject: RE: Security restrictions

I am pretty sure this will be the problem. Run ‘agent test’ analysis and it will tell you! You are performing a restricted operations, and a common mistake is not to set the security tab info (new to R6).

If you check Agent FAQ’s “Troubleshooting agents in R6” article it has common gotchas like that are listed. “Agent test” will diagnose this problem as well. Not familiar with “Agent test”? “Troubleshooting agents” covers this tool as well.

Subject: Agent - Newly created or modified documents

The question posted earlier is a good one. Are you sure it runs on “new or modifed” documents? In other words, does the agent simply not run? Does it skip over the document? Does it bomb out with an error? Are there any errors in the server log? The code shown does not do any error checking/logging/debugging. How do you know what is happening when it fails?

I would guess the problem is with the $HasItem. I don’t remember any version specific issues here, but I wouldn’t be surprised if attachments were not embedded differently by the old admin client, in which case, you need to bring the agent up to date. The next likely problem area would be restricted rights to the directory or to the file that gets saved on the server.