Manage Learn to apply best practices and optimize your operations.

Extracting query string parameters in agents

This code will produce a LotusScript list of key value pairs representing the query string passed to the agent in the form

This code will produce a LotusScript list of key value pairs representing the query string passed to the agent in the form:-


The list will allow you to extract these parameters like this:

lstParams( "fred" )
IsElement( lstParams( "bedrock" ) )

The code uses the LotusScript Evaluate command to process the QUERY_STRING_DECODED and make it into an array. It is very simple to understand and because it uses the QUERY_STRING_DECODED there is no need to decode the string as Domino does this for us!

The keys for the list are converted to lowercase as it is easy to pass parameters that are in the wrong case. The case of the values is left unaltered.

To call the function, use the code in the Initialize sub.

sub Initialize
	Dim session As New NotesSession
	Dim docCurrent As NotesDocument
	Dim lstParams As Variant
	lstParams = funGetQueryParameters( docCurrent.QUERY_STRING_DECODED(0) )
	Forall sValue In lstParams
		Print Listtag( sValue ) & "=" & sValue & "<br>"
	End Forall
End Sub

Function funGetQueryParameters( sQueryString As String ) As Variant

Given the QUERY_STRING_DECODED, return a string list containing key value pairs

	Const FORMULA_EXPLODE_QS_2 = |";"&")|
	Const FORMULA_EXPLODE_PAIR_2 = |";"=")|
	Dim lstParams List As String
	Dim vAllPairs As Variant
	Dim vPair As Variant
	vAllPairs = Evaluate( FORMULA_EXPLODE_QS_1 & sQueryString & FORMULA_EXPLODE_QS_2 )
	Forall sPair In vAllPairs
		vPair = Evaluate( FORMULA_EXPLODE_PAIR_1 & sPair &
FORMULA_EXPLODE_PAIR_2 ) 'The line below catches the situation where there is no
pairing, ie just a single 'key name with no value. In this case the key and value are the same lstParams( Lcase(vPair(0)) ) = vPair( Ubound( vPair ) ) End Forall funGetQueryParameters = lstParams End Function

Dig Deeper on Lotus Notes Domino Administration Tools

  • Favorite iSeries cheat sheets

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