Is it possible to have an agent (written in formula language) run when a document is opened (viewed) in a browser so that it writes out some of the details of the document being opened to a new database that I created?
If so, how do I code the agent?
Subject: Using Formula to write a record to a new database
Formula language may or may not be the optimal solution depending on what exactly you want to do, which you have not spelled out in your post. More detail leads to better answers.
Subject: Using Formula to write a record to a new database
You can not create new documents in background formula/simpleaction agent. You can copy existing documents and thus emulate creation of new document, but I am not sure if you can get handle to that new document in a reasonably easy way.Formula agent can not change fields in documents in another databases.
Easiest for your logging function would be to create a LotusScript agent. You can invoke that LS agent from your original database by putting following code into “HTML HEAD CONTENT” of the form:
“<link href="http://www.company.com/resources/styles.nsf/webstyle1.css!open"+"\” rel="stylesheet" type="text/css">"
Agent webstyle1.css in resources\styles.nsf
“Acts on property:” Run Once
Sub Initialize
Dim session As New notessession
Set db=session.currentdatabase
Set doc=session.documentcontext
Set logdoc=New notesdocument(db)
logdoc.form="Logdoc"
logdoc.querystring=doc.query_string(0)
logdoc.RemoteUser=doc.Remote_Addr(0)
logdoc.referer=doc.HTTP_Referer(0)
Set notesItem = New NotesItem( logdoc, "DocReaders", "[Manager]", READERS)
Call logdoc.save(True,False)
Print "//"
End Sub
Results of logging you can see in resources\styles.nsf in a view you create. Do not forget to create “Manager” role in that database.
Subject: RE: Using Formula to write a record to a new database
Thanks for that.
I will give it a go. (Haven’t learnt LS yet, so it could be fun).
Regards