On my Web application, I have an Lotus Script agent which is to be called during the WebQueryOpen of a form.In the agent, I need to trigger an alert using JavaScript.
The alert doesn’t work if I run the agent during WebQueryOpen. But, if I call the agent using an action button on a form, the alert works.
Any suggestions on how do I make it work during WebQueryOpen?
Thanks in Advance.
Below is my code:
Sub Initialize
Dim session As New NotesSession
Dim profiledoc As notesdocument, db As notesdatabase
Dim lockDBReplicaID As String, ServerName As String, lockDB As notesdatabase
Dim doc As notesdocument, lockdoc As notesdocument
Dim collection As notesdocumentcollection, selection As String
Set db = session.CurrentDatabase
Set profiledoc = db.GetProfileDocument( “Profile” )
If profiledoc.HasItem( “LockDBReplicaID” Then
lockDBReplicaID =profiledoc.GetFirstItem( "LockDBReplicaID" ).text
Else
Goto ForceOK
End If
ServerName = db.Server
Set lockDB = New NotesDatabase( "", "")
Call lockDB.OpenByReplicaID ( ServerName, LockDBReplicaID )
If Not( lockDB.IsOpen ) Then Goto ForceOK
Set collection = Nothing
selection = "Form = ""Lock""" & " & LockDocID = """ & idoc.UniversalID & """"
Set collection = lockDB.Search( selection, Nothing, 0 )
If collection.Count > 0 Then
Set lockdoc = collection.GetFirstDocument
msg ="The doc is locked...."
alertmd(msg)
CheckDocLocks = False
Else
ForceOK:
CheckDocLocks = True
End If
End Sub
Below is the code for function alertmd in agent:
Function alertmd(msg)
Msgbox msg
Print "<SCRIPT LANGUAGE=JavaScript>"
Print "alert(""" & msg & """)"
Print "</SCRIPT>"
End Function