PROGRAMMING DOMINO FOR WEB APPLICATIONS
To run the agent, you can enter the OpenAgent URL command wherever URLs are permitted, for example:
http://localhost/Web+test.nsf/Change+Status+to+Closed?OpenAgent
Or activate an action or hotspot that contains the following code:
@Command([ToolsRunMacro]; "(Change Status to Closed)")
The WebQueryOpen event on the form calls the agent "ChangeHeadText." The target is "None." The code is:
@Command([ToolsRunMacro]; "ChangeHeadText")
ChangeHeadText contains the following formula. When a document based on this form is opened from a browser, WebQueryOpen causes HeadText to be changed; when a document is opened from Notes, HeadText remains as is.
FIELD HeadText := "This document is being opened from a browser at " + @Text(@Now); @All
Here is the code:
Sub Initialize Dim s As New NotesSession Dim db As NotesDatabase Dim dc As NotesDocumentCollection Dim doc As NotesDocument Dim arg As String, p1 As Long arg = s.DocumentContext.Query_String(0) p1 = Instr(arg, "&") If p1 = 0 Then Print "Need argument 'Open' or 'Closed'" Exit Sub Else arg = Lcase(Mid$(arg, p1 + 1)) If arg <> "open" And arg <> "closed" Then Print "Argument must be 'Open' or 'Closed'" Exit Sub End If End If arg = Ucase(Left$(arg, 1)) + Right$(arg, Len(arg) - 1) Set db = s.CurrentDatabase Set dc = db.UnprocessedDocuments Set doc = dc.GetFirstDocument Do While Not(doc Is Nothing) doc.Status = arg Call doc.Save(False, True) Set doc = dc.GetNextDocument(doc) Loop Print "<B>Status changed to "+ arg + " in all documents</B>" End Sub