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:-

http://server/db.nsf/agWeb?OpenAgent&Fred=Wilma&Barney=Betty&BedRock

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.
Enjoy!
 

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
	
%REM

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

%END REM
	
	Const FORMULA_EXPLODE_QS_1 = |@EXPLODE( "|
	Const FORMULA_EXPLODE_QS_2 = |";"&")|
	Const FORMULA_EXPLODE_PAIR_1 = |@EXPLODE( "|
	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
This was first published in May 2002
This Content Component encountered an error

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchDataCenter

SearchExchange

SearchContentManagement

Close