We’re trying to web-enable our Notes databases. The following is in a LotusScript agent that is called from a button on a form. It works fine when a Notes client is used, but nothing happens when a browser (IE) is used. I don’t know how to troubleshoot this without a script debugger. What’s in this code that would not work in a browser, and how do I work around it?
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim docMemo As NotesDocument
Dim lookupView As NotesView
Dim lookupDoc As NotesDocument
Set db = session.CurrentDatabase
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
If Not doc.EmailSent(0) = “Yes” Then
Set docMemo = db.createdocument
docMemo.Form = "Memo"
Set rtitem = docMemo.CreateRichTextItem( "Body" )
Call rtitem.AppendText("Body text goes here.")
Set lookupView = db.GetView( "LookupContacts" )
Set lookupDoc = lookupView.GetDocumentByKey( "ChangeManager" )
docMemo.SendTo = lookupDoc.Contact
docMemo.Subject = "Subject line here."
Subject: RE: LotusScript agent fails with browser (web)
You can debug on the web using error handling routines
On Error goto errorhandler
then at the end of your code add
Exit sub
errorhandler:
do whatever you want
End Sub
You can use msgbox which writes to the server console, print which writes to the browser, write to a notes log or send yourself an email all with the line and error code.
Subject: RE: LotusScript agent fails with browser (web)
Right click on the agent in designer to get the agent log which will tell you the last time the agent ran.
The agent can not be running as both print and msgbox work in a webquerysave agent and there is nothing wrong with your email code so at the very least you should receive an email if the agent was running.
A couple of things to check are if the agent is signed by yourself do you have rights to run lotusscript agents on the server and also the agent selection criteria. Set it to run from Agent List selection with a target of none.
Another thing that may or may not be an issue as I have never tried to do it this way is the lines of code after you run the agent
Subject: RE: LotusScript agent fails with browser (web)
The agent log indicates it IS running, but I still get nothing when triggered from a browser. (And it continues to work fine when run from a Notes client.) The agent is signed by me, and I have rights to run on the server. (My other script agents in this database work fine.)
It’s set to run from Agent List with a target of None.
Note that the commands after the agent call do work: The document saves and the redirection works fine. It’s just that this agent can’t seem to send any mail or generate any messages.
Subject: RE: LotusScript agent fails with browser (web)
After you have called your agent the formula will not wait until the webquerysave agent has completed to run your fileSave and UrlOpen
What I’m thinking which may be nonsense is that you start the agent but then the following formulas run which interrupt the agent causing it to stop running.
Test it out by commenting out these two lines so that you are only calling the agent and then add to your agent at the beginning.
Subject: RE: LotusScript agent fails with browser (web)
I’ve tried removing the other lines so that only the agent is called, but got the same result.
BUT this is interesting. I changed the agent to this…
Print "In agent..."
Dim progress As Integer
progress = 0
Print progress
Dim session As New NotesSession
progress = 1
Print progress
Dim db As NotesDatabase
progress = 2
Print progress
Set db = session.CurrentDatabase
progress = 3
Print progress
Dim errorMemo As NotesDocument
progress = 4
Print progress
Set errorMemo = db.CreateDocument
progress = 5
Print progress
errorMemo.Form = "Memo"
progress = 6
Print progress
errorMemo.SendTo = "myMailAddress"
progress = 7
Print progress
errorMemo.Subject = "Starting agent"
progress = 8
Print progress
errorMemo.Send( False )
progress = 9
Print progress
…and it prints up through 9 in both cases – triggered from a browser and triggered from a Notes client. However, I don’t get any mail when triggered from a browser.
Subject: RE: LotusScript agent fails with browser (web)
I have run this code in an agent called from the webquerysave event and receive an email and the following output
In agent… 0 1 2 3 4 5 6 7 8 9
I also tried adding the FileSave and URlOpen commands after calling the agent and found that they make no difference although the UrlOpen did not work. You do not need the FileSave as the document must already being saved for the webquerysave event to run and you can redirect the user in the agent - example below
Print {}
I would have thought that if your server was unable to send the email then it would throw an error and you would not get to the line where 9 is printed to the browser. Do you have other agents that send emails which run on the server Ok? If so then I have no idea what the problem is.
Subject: RE: LotusScript agent fails with browser (web)
Marc, how do you launch the agent from the web? You can’t use Notes Form methods (like QuerySave, PostOpen, etc…), but you can only use WebQuerySave and WebQueryOpen to call an LotusScript agent by Form actions. In addition you can also call an LotusScript agent from a button, but you can’t put the LotusScript code directly into the button, the agent must be called via @Command([ToolsRunMacro];“YourLotusScriptAgent”). The third option is to call the agent directly via URL, but in this case you probably don’t need that.
Subject: RE: LotusScript agent fails with browser (web)
The agent is called via a button using @Command([ToolsRunMacro];“(QuestionNotifications)”). After calling the agent, the doc is saved, the user is presented with a “thank you” page, and then redirected to where they were before submitting the question. Here’s the complete button code…
Subject: RE: LotusScript agent fails with browser (web)
You should not use any other commands than the @Command([ToolsRunMacro];…). You can do the other commands from within the LotusScript agent, like saving the document and opening another URL.
Subject: LotusScript agent fails with browser (web)
Note: The default access for viewing and running is All readers and above. But I’ve also tried checking “Run as web user,” “Run on behalf of (me),” setting runtime security level to allow restricted operations with full admin rights, and checking “Allow Public Access users to view and run.”