(Options) Option Public Option Declare Use "SomeScriptLibrary" ' this library contains all scripts to actually process these requests %REM ------------ AJAX Agent Sample ------------------- web agent for AJAX calls URL parameters: action - required - selects the action/custom code to execute *optional: other parameters as required by a given action all url params will be placed in the params List %END REM (Declarations) Dim s As NotesSession Dim db As NotesDatabase ' this db Dim doc As NotesDocument ' documentcontext Dim path As Variant ' webpath Dim params As Variant ' list of past parameters Sub Initialize ' setup environment - see Options for description of agent use Set s = New NotesSession Set db=s.CurrentDatabase Set doc = s.DocumentContext ' get passed action parameters path = Evaluate( "@webdbname" ) params = getParams( "url", Strright( doc.Query_String(0), "&"), "*") ' process each action -- each action is function sent by JS If Iselement( params( "action" )) Then Select Case Lcase( params( "action" )) Case "someactions" ' used by the SampleForm Call ActionFunction(params("docunid")) ' Function contained in included script library under Options '********************** ADD OTHER CASE's HERE ****************** Case Else Print "***Parameters Invalid***" End Select End If Exit Sub End Sub Function GetParams( listtype As String, rawvalues As String, varname As String ) As Variant 'Listtype is either: 'url' or 'cookie' to determine the separator Dim paramArray As Variant Dim sep List As String 'separators mapping Dim decode As Variant Dim allValues List As String GetParams = "" listtype = Lcase( listtype ) varname = Lcase( varname ) sep( "url") = "&" sep( "cookie") = ";" Select Case listtype ' only cases handled are url or cookie Case "url", "cookie" If listtype = "url" Then decode = Evaluate( |@urldecode( "Domino"; "| & rawvalues & |")| ) rawvalues = decode(0) End If paramarray = Split( rawvalues, sep( Lcase( listtype))) If varname = "*" Then Forall pair In paramarray allValues( Strtoken( pair, "=", 1 )) = Strtoken( pair, "=", 2 ) End Forall GetParams = allValues Else Forall param In paramArray If Lcase( Strtoken( param, "=", 1)) = varname Then GetParams = Strtoken( param, "=", 2) Exit Forall End If End Forall If listtype = "url" Then decode = Evaluate( |@urldecode( "Domino"; "| & getParams & |")| ) Getparams = decode(0) End If End If Case Else GetParams= "ERROR: GetParam - Invalid ListType for Function" End Select End Function