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.
Copyright © 2000 - 2024 Jake Howlett of Rockall Design ltd. This article was printed from codestore.net