Reading QueryString easier
Function getArgumentValue() can be used in LotusScript Web agents to parse argument values from QueryString. Function recognizes both arguments with an assigned value (like ProdID=123456) and also arguments without a value (like ShowStat).



Download: IT Certifications 101
Inside this exclusive essential guide, our independent experts break down which IT certifications are worth your time and effort, and how to get started obtaining them to further your career— including specific certifications that any cloud or desktop pro should seriously consider.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
You also agree that your personal information may be transferred and processed in the United States, and that you have read and agree to the Terms of Use and the Privacy Policy.
Rules:
If argument is not present in QueryString, function returns an empty string. If argument with assigned value is present, it returns its value. If argument without assigned value is present, it returns "1".
Code: Function getArgumentValue(queryString As String, argName As String) As String Dim delimiter As String, qs As String, pos As Integer Dim posVal As Integer, partR As String delimiter = "&" qs = delimiter + queryString + delimiter pos = Instr(1, qs, delimiter + argName + "=", 1) If pos > 0 Then partR = Right(qs, Len(qs) - (pos + 1 + Len(argName))) getArgumentValue = Left(partR, Instr(partR, delimiter)- 1) Else pos = Instr(1, qs, delimiter + argName + delimiter, 1) If pos > 0 Then getArgumentValue = "1" Else getArgumentValue = "" End If End If End Function EXAMPLE: Simple web agent: Sub Initialize Dim session As New NotesSession Dim docContext As NotesDocument Dim qs As String Set docContext = session.DocumentContext qs = docContext.Query_String_Decoded(0) Print "<pre>" Print "Product ID: " + getArgumentValue(qs, "ProdID") Print "Action: " + getArgumentValue(qs, "Action") Print "ShowStat: " + getArgumentValue(qs, "ShowStat") Print "Send Notification: " + getArgumentValue(qs, "SendNotif") Print "</pre>" End Sub Agent called from browser with following URL http://localhost/tester.nsf/QSReader?openagent⪻odID=123456&Action=Remove&ShowStat returns these results: Product ID: 123456 Action: Remove ShowStat: 1 Send Notification:
Start the conversation
0 comments