Manage Learn to apply best practices and optimize your operations.

Reading QueryString easier

Function getArgumentValue() can be used in LotusScript Web agents to parse argument values from QueryString. Function recognizes both arguments with an assigned value (like ProdID=123456) and also arguments without a value (like ShowStat).

Rules:
If argument is not present in QueryString, function returns an empty string. If argument with assigned value is present, it returns its value. If argument without assigned value is present, it returns "1".

Code: Function getArgumentValue(queryString As String, argName As String) As String
	Dim delimiter As String, qs As String, pos As Integer
	Dim posVal As Integer, partR As String
	delimiter = "&"
	qs = delimiter + queryString + delimiter
	pos = Instr(1, qs, delimiter + argName + "=", 1)
	If pos > 0 Then
		partR = Right(qs, Len(qs) - (pos + 1 + Len(argName)))
		getArgumentValue = Left(partR, Instr(partR, delimiter)- 1)
	Else
		pos = Instr(1, qs, delimiter + argName + delimiter, 1)
		If pos > 0 Then
			getArgumentValue = "1"
		Else
			getArgumentValue = ""
		End If
	End If
End Function


EXAMPLE: Simple web agent: 

Sub Initialize
	Dim session As New NotesSession
	Dim docContext As NotesDocument
	Dim qs As String
	
	Set docContext = session.DocumentContext
	qs = docContext.Query_String_Decoded(0)
	
	Print "<pre>"
	Print "Product ID: " + getArgumentValue(qs, "ProdID")
	Print "Action: " + getArgumentValue(qs, "Action")
	Print "ShowStat: " + getArgumentValue(qs, "ShowStat")
	Print "Send Notification: " + getArgumentValue(qs, "SendNotif")
	Print "</pre>"
End Sub

Agent called from browser with following URL
http://localhost/tester.nsf/QSReader?openagent&ProdID=123456&Action=Remove&ShowStat

returns these results:

Product ID: 123456
Action: Remove
ShowStat: 1
Send Notification:

Dig Deeper on Domino Resources - Part 6

SearchWindowsServer

Search400

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

  • HTML cheat sheet

    This is a really cool cheat sheet if you're looking to learn more about HTML. You'll find just about everything you every wanted ...

  • Carol Woodbury: Security

    Carol Woodbury

SearchDataCenter

SearchContentManagement

Close