Alert for WebQueryOpen agent

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


Subject: alert for WebQueryOpen agent

Hi

When u use print message in WQO agent that statement overwrites by form. It will be possible by assigning ur script to one variable.

locdoc.msg = alertmd(msg)

Function alertmd(msg)

msg =“”

alertmd = msg

End Function

Subject: RE: alert for WebQueryOpen agent

And another way is to have the onload event of form look for the value of a field on the form that can be set via LotusScript, and pop up the alert if the value matches.

HTH, George :slight_smile:

Subject: RE: alert for WebQueryOpen agent

Here is something that I used when I used LotusScript for the web. (I use Java now)

Sub PrintThankYou (serverName As String, databaseName As String)

Dim message As String

Dim url As String



message = "Thank you, your approval has been recorded."

url = "http://" + serverName + "/" + databaseName



Print "<SCRIPT LANGUAGE=""JavaScript"">alert('" & message & "');top.location='" & url & "';</SCRIPT>"

End Sub