Notes Ninjas Notes Ninjas
Lotus Notes hints, tips, error messages
Get value from query string function

Hint Short Cut: Add this to your code & documentation to help you find this page.
http://www.notesninjas.com/#GetValFromQs or http://www.notesninjas.com/A555F9/nn.nsf/ByAlias/GetValFromQs


I keep reusing this function so I'll stick it here for others to use. It just grabs a value from a url.





 

In your agent use this code:

 Dim s As New notessession
Dim db As notesdatabase
Set db = s.currentdatabase
Dim doc As notesdocument
Set doc = s.documentcontext
 
qs=doc.Query_String_Decoded(0)
 
unid=getvalfromqs(qs,"unid")

 

 

In the Initialise or options area of your agent paste this:

Function getvalfromqs(Byval qs As String, Byval fld As String) As String
 'this function gets the value of a field from a string

'in the string the format shoul dbe ...&FIELDNAME=jssdjfhsdj
'the nd of the value is delimited by end of string or another &

On Error Goto errhdlr

a=Instr(qs,"&" & fld & "=")
If a=0 Then
 getvalfromqs="not found in string"
 Exit Function
End If

b = Instr(a+2+Len(fld), qs,"&")
If b=0 Then b=900 ' if end of string then return rest

getvalfromqs=Mid$(qs, a+2+Len(fld), b-(a+2+Len(fld)) )
Exit Function

errhdlr:
On Error Resume Next
Print "Error: getvalfrom qs: " & Error$ & "   " & Err & "   erl:" & Erl & "<br>"
getvalfromqs="Error: getvalfrom qs: " & Error$ & "   " & Err & "   erl:" & Erl
Exit Function

End Function

You can use Query_String_Decode or Query_string .

If you are using @formula with servers after R6 you can use the inbuilt function: @UrlQueryString instead:

for example:

http://www.adfos.com/af.nsf?Opendatabase&review=theBest&Category=LotusNotes

@URLQueryString would return an array of

Opendatabase
review=theBest
Category=LotusNotes

@OurlQueryString("Category")

would return

LotusNotes

 

For completeness Notes 4 developers would use:

 @middle(Query_String;"&Category=";"&")

 

 

 

 

 

 

 


 Jump to:     Notes Tips
    Lotus Notes Index 
  Register for Tips
Previous Lotus Notes Tip 
    Next Lotus Notes Tip
Your company logo here?
Adam Foster
Free Cash Making Web Site
Free Revenue Earning Blog Site
 Free Revenue Earning Newsletter Site   
Free Search Pages Free Web stats
Free Contact Us page
Cheap .com domain names
 Need a website or 
   Lotus Notes
  problem solved?
Adam Foster
Web Services Platform Architecture: Soap, WSDL, WS-Policy, WS-Addressing, WS-Bpel, WS-Reliable Messaging and More by Francisco Curbera, Frank Leymann, Tony Storey, Donald Ferguson, Sanjiva Weerawarana
Other books claim to present the complete Web services platform architecture, but this is the first one I've seen that really does. The authors have been intimately involved in the creation of the architecture. Who better to write this book?
See at: Amazon.co.uk | Amazon.com |