What is the best approach? We have a clinic applicaiton that I want to extract data from the url. The programmer of the clinic app can send the url with the value that I need, but I am not what to do from here. When the programmer sends the url, I want to create a domino document with and populate a Domino field from the value within the url. I am newer to web development. Thanks for your help.
Subject: QUERYSTRING and extract value
If the querystring comes in with name-value pairs, there are multiple ways you can do this. There’s a reserved field in Domino called query_string. If you make this computed and add it to your form, you can then have your other fields parse out values using @RIght, @Left, @Middle, etc.
Or, if you’re doing this via agent, there are a couple of custom functions that can help.
Call like so:
newDoc.returnVw = Unescape(Parse(docContext.Query_String(0), “vwAlias”))
newDoc.key = Unescape(Parse(docContext.Query_String(0), “ProdID”))
newDoc.prefID = Unescape(Parse(docContext.Query_String(0), “UserPrefID”))
where the query_string looks like this:
http://mydomain/mydatabase/myform?OpenDocument&vwAlias=testView&prodID=1224&UserPrefID=abc
Function Parse( StringToParse As String, ParameterName As String ) As String
REM Constants and Variables for parsing the Input String
Const EqualSign = “=”
Const Separator = “&”
Const PlusSign = “+”
Const NotFound = “Not Found”
Dim Found As Long
Dim StartPos As Long
Dim SeparatorPos As Long
Dim ParameterValue As String
Dim lenParameterName As Integer
Dim lenParameter As Integer
Dim InputString As String
Dim lenInput As Long
Dim CharacterCount As Integer
InputString = StringToParse
lenInput = Len( InputString )
REM Parse the Parameter
ParameterName = ParameterName & “=”
lenParameterName = Len( ParameterName )
Found = Instr( 1, InputString, ParameterName )
If Found > 0 Then
StartPos = Found + lenParameterName
SeparatorPos = Instr( Found, InputString, Separator )
If SeparatorPos > Found Then
lenParameter = SeparatorPos - StartPos
REM Unescape the Parameter Value (convert + to space)
For CharacterCount = 1 To Len( ParameterValue )
If Mid$( ParameterValue, CharacterCount, 1 ) = PlusSign Then Mid$( ParameterValue, CharacterCount, 1 ) = " "
Next
Else ’ Is this the last one?
lenParameter = lenInput - StartPos + 1
End If
ParameterValue = Mid$( InputString, StartPos, lenParameter )
StartPos = SeparatorPos + 1 ’ Setup for next parameter search
Else
StartPos = 1 ’ Didn’t find it, so reset StartPos
End If
Parse = ParameterValue
'Print ParameterName & Parse & “
”
End Function
Function Unescape( InputString As String ) As String
PercentPos = Instr( 1, InputString, “%” )
Do While PercentPos > 0
InputString = Left( InputString, PercentPos - 1 ) + Chr$( “&H” + Mid$( InputString, PercentPos + 1, 2 ) ) + Mid$( InputString, PercentPos + 3 )
PercentPos = Instr( PercentPos + 1, InputString, “%” )
Loop
PercentPos = Instr( 1, InputString, “+” )
Do While PercentPos > 0
InputString = Left( InputString, PercentPos - 1 ) + " " + Mid$( InputString, PercentPos + 1 )
PercentPos = Instr( PercentPos + 1, InputString, “+” )
Loop
Unescape = InputString
End Function
Subject: RE: QUERYSTRING and extract value
Thank You Esther. You ROCK!!
Subject: QUERYSTRING and extract value
If this is a notes form displayed on the web then you need to make sure you have a hidden field (doesn’t have to be hidden, but there is generally no need to show it either) named QUERY_STRING. If it’s a regular page (for instance generated by print statements from an agent) then the field will be there for you already. So then you just need to get a handle to the document context (notesdocument = system.documentcontext) and get the value of QUERY_STRING.
That value will be everything after the question mark in the URL. From there you can just populate a variant with the split values on ampersands:
variant = Split(queryStringValue, “&”)
Now you have an array of value pairs. You can further separate these with another split on equals to get the key/value pair.