Friday, September 7, 2012

Getting a QueryString parameters using Lotus Script

According to Lotus notes agents, other than note id we cant send parameters to a lotus notes agent.
But there is traditional way to pass parameters to the lotus script agent by sending as query string in the notes url. I will be sent while calling the agent by URL.

So, we have passed the parameters in the URL. Now we have to get the query string and need to decode it(ie. seperate them as a parameter and value). The following function will do that job.

Function DecodeQueryString(QueryString As String)
 On Error GoTo errorHandler

 Dim i As Integer
 Dim varname As String
 Dim value As String
 Dim Params List As String
 i = InStr(QueryString, "&" )
 Do While i>0
  QueryString = Mid(QueryString, i+1)
 
  i=InStr(QueryString,"=")
  If i>0 Then
   ' Get the QueryString Name
   varname = Left(QueryString,i-1)
  Else
   Exit Do
  End If
  QueryString=Mid(QueryString, i+1)
 
  i=InStr(QueryString,"&")
  If i>0 Then
   ' Get the Value
   value = Left(QueryString, i-1)
  Else
   value=QueryString
  End If
  ' Save the Parameter in the list
  Params(varname) = Replace(value,"%20"," ")
 Loop
 Exit Function
errorHandler:
 MsgBox "(agNewRequest):DecodeQueryString() : " + Error() + "  & Line No :  " + CStr(Erl())
 Exit Function
End Function

I hope this helps you a lot...
 

No comments:

Post a Comment