I have an agent, posted below, that is called from the web. Is there a way I can grab the URL that is calling it ?
As you can see I have tried HTTP_Referrer(0) but that isn’t working.
Thanks
Paul
Sub Initialize
Dim session As New NotesSession
Set doc = session.DocumentContext
Print doc.HTTP_Referrer(0)
End Sub
Subject: can an agent called from the web know the url that is calling it ?
Maybe it’s a type error , but in designer help the cgi var is called HTTP_Referer=The URL of the page the user used to get here.
ONE r not 2
Subject: RE: can an agent called from the web know the url that is calling it ?
thanks for that - it has changed the error message but it still doesn’t work !!
any other ideas anyone ?
thanks
paul
Subject: RE: can an agent called from the web know the url that is calling it ?
weird but it does work but I needed to add another string infront of it to get it to display !!
Dim strReturnResults As String
strReturnResults = “not blank” & doc.HTTP_Referer(0)
Thanks anyway
Paul
Subject: RE: can an agent called from the web know the url that is calling it ?
Try converting to string with Cstr
Subject: HTTP_Referer(0) not a proper string??
Calin
Thanks for that but Cstr doesn’t work.
Does anyone know what is going on here ?
Thanks
Paul
Subject: RE: HTTP_Referer(0) not a proper string??
HTTP_Referer(0) certainly is a proper string. Have you tried Printing a hard-coded complete URL in that exact context as a test?
Subject: HTTP_Referer(0) is a proper string
Stan
quite right the error lay elsewhere !!
what a waste of time for all concernetd that was.
thanks
paul
Subject: Sorry misread the question.
This agent parses Query_String to extract one argument, which must be “Open” or “Closed.” It must be run with an OpenAgent URL command, for example,http://localhost/Web+test.nsf/Change+Status?OpenAgent&Closed
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 "Status changed to “+ arg + " in all documents”
End Sub