Using Query_String parameters

Jake Howlett, 25 October 2000

Category: Forms; Keywords: URL Query String Decoded

Using the Query String portion of a URL is a useful method to pass information to a new document. For example when creating a new repsonse document:

..db.nsf/response?OpenForm&ParentUNID=766a4d...

Getting this value would be relatively easy. However, if the Query String consisted of multiple sets of arguments it gets a little more complicated. This method makes it simple to find a value in your form, using Formula language.

First thing to do is to create two Computed For Display, Multi-Value, Text fields with New Line to separate and display entries. I usually put these in to a Common Fields subform so that they are available in every form I use, just in case. This is also a good place to put the "Query_String" and "Query_String_Decoded" fields. Make these Computed For Display with a value the same as their name. These fields MUST appear on the form somewhere in order for Domino to be able to reference them.

The first field is called "ArgNames" and its formula is:

@Left(@Explode(@Right(Query_String_Decoded;"&");"&");"=")


The second field is called "ArgValues" and its formula is:

@Right(@Explode(@Right(Query_String_Decoded;"&");"&");"=")


Note: We have used Query_String_Decoded here and not, the more well known, Query_String CGI variable. I won't patronise you by explaining the difference...

Now that we have our lists of parameters we can use them throughout our forms. Let's say we have a field called "FirstName", whose default value we want to get from a parameter called "fName" in the URL. Place the following in to the Default Value event of the field:

@Replace("fName";ArgNames:"fName";ArgValues:"")


If the "fname" parameter is in the "Query_String" portion of the URL then its corresponding value is extracted from the "ArgValues" field. If not then a blank "" will be added.

We could use this in lots of other places as well, such as the Window Title or in Computed Text areas. Also, making the Computed For Display fields hidden would then make them available to JavaScript in the browser.


Note: In R5 there is a new "un-documented" @Formula called @GetMembers.

@GetMembers( sourceList; start; count)

sourceList = List from which you want to obtain value
start = position in list to start getting items (number)
count = number of items to return (number)

So, in the above example the code would then be simplified to:

REM "Check that the parameter exists";
pos:=@Member("fname";ArgNames);
@If(pos>0; @GetMembers(ArgValues; pos; 1); "")