Load a webpage after agent runs

Hi,

I have an agent, which is working properly - but how do i do the following :

In the agent there is an IF statement. IF it is true I want to save the current document and load the homepage. If it is false I want to display a prompt on the screen.

Any help would be great as I’m new at NotesWEb.

F1H

Subject: Load a webpage after agent runs

Hi, I post it, I hope it help you. Regards.

Agents cannot run in a browser. They can be activated from a browser but run on the Domino server containing the agent.

Setting up a Web agent

Using the Agent Properties box, do the following:

Check the “Shared” option when you create the agent.

Set the agent trigger to “On event” and either “Agent list selection” or “Action menu selection.”

Set the agent target to either:

“None” for agents that work on the current document such as those launched from WebQueryOpen or WebQueryClose, or a form action or hotspot that works on fields in the current document.

“All documents in database” for agents that work on existing documents such as those launched from the OpenAgent URL or a view action. The actual documents processed depend on the agent code, for example, the SELECT statement in a formula or the UnprocessedDocuments property in LotusScript.

Check “Run as web user” on the Security tab to run the agent using the browser login name. Otherwise the agent runs with the rights of the agent signer.

Agent code axample:

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim arg As String, p1 As Long



arg = s.DocumentContext.Query_String(0)

p1 = Instr(arg, "&0")

p2 = Instr(arg, "&1")

pFIN = Instr(arg, "!FIN")

If p1 = 0 Or p2=0 Then

	

	Print "<SCRIPT LANGUAGE = JavaScript>"

	Print "alert('Error, debe introducir el valor del campo Clave')" 

	Print "path = window.location.pathname.toLowerCase();" 

	Print "var nsfPos = path.indexOf('.nsf');"

	Print "path=path.substr(0,nsfPos+5);"

	Print "servidor=window.location.hostname"

	Print "var docto='http://'+servidor+path+'/001Unidad?OpenForm"

	Print "</SCRIPT>"

	

	Exit Sub

Else

	vuoClave = Mid(arg, p1 + 2, p2 - p1 - 2)

	vuoCID = Mid(arg, p2 + 2, pFIN - p2 - 2)

	

	Set db= s.currentdatabase

	Set view = db.GetView( "001UnidadXClave" )

	Set doc = view.GetDocumentByKey( vuoClave )

	If Not (doc Is Nothing) Then

		vuoCanSave = "SI"

		Print "<SCRIPT LANGUAGE = JavaScript>"

		Print "alert('Ya existe la unidad  " + vuoClave +"  no se guardará el documento')" 

		Print "path = window.location.pathname.toLowerCase();" 

		Print "var nsfPos = path.indexOf('.nsf');"

		Print "path=path.substr(0,nsfPos+5);"

		Print "servidor=window.location.hostname"

		Print "var docto='http://'+servidor+path+'/001Unidad?OpenForm"

		Print "</SCRIPT>"

	Else

		vuoCanSave = "SI"

		Print "<SCRIPT LANGUAGE = JavaScript>"			

		Print "path = window.location.pathname.toLowerCase();" 

		Print "var nsfPos = path.indexOf('.nsf');"

		Print "path=path.substr(0,nsfPos+5);"

		Print "servidor=window.location.hostname"

		Print "var docto='http://'+servidor+path+'/001Unidad?OpenForm&" +vuoClave+"&"+vuoCanSave+"'"

		Print "location.href=docto;"

		Print "</SCRIPT>"			

	End If	

	

	Exit Sub

End If

End Sub

Subject: RE: Load a webpage after agent runs

Hi.

Thanks for your help. it is loading the correct website now. I only have one remaining question…how do I pop-up a box on the screen on the web? either in the LotusScript Agent or in Formula?

Thanks

Subject: RE: Load a webpage after agent runs

In the sample code you can see an alert command, it´s better for Javascript. I don´t know if a Messagebox or Msgbox command run in a browser, but you can try.

Regards.

Subject: RE: Load a webpage after agent runs

I’ll just add that the answer to the implied question here is NO. LS messageboxes do not add dialog boxes to the browser. You must do this in Javascript.

Subject: RE: Load a webpage after agent runs

Thanks to all who replied,

  • Ok, so how do i call my lotusscript agent using Javascript?

  • Also, may be of use for me to also know the Javascript replacement for @Command([Compose]).

Thanks

Subject: Load a webpage after agent runs

Hi,

Not knowing which language you are using:

in LotusScript: Print “[http://www.website.com]”

in @Formula : @UrlOpen(“http://www.website.com”)

and in both cases you can compute an address to use.

/Palle