Search code examples
htmllotus-noteslotus-dominolotusscript

lotus agent request_content how to separate fields


I have a lotus agent running with lotusscript. Form the browser I post form data to the webserver and I receive this data with the following lotusscript:request_method = doc.GetItemValue( "request_content" )(0)

But if I have a form with for example name and phonenumber. Then my agent receives this as name=bla&phonenumber=243525

How can i separate these fields actually and secondly how can I receive XML on this agent so that I can extract this and put in to a document. I googled a lot but still got no solutions.


Solution

  • The way you get the data differs if the client makes a GET or a POST. If this is a get, all the parameters are in the url in a url format.

    Many many ressource on the web will give you some code to parse this url and get name and value a simple search in goolge will bring : http://searchdomino.techtarget.com/tip/Parsing-URL-Parameters-with-Ease

    I use generally the following code, which add in the document context the fields received on url or on post.

        Dim s As NotesSession
    Set s = New notessession
    Set doc = s.documentcontext
    Dim myQuerystring As String
    
    If doc Is Nothing Then
        logErrorEX "getting a call without document context ?!?","", doc,""
        GoTo returnErr
    End If
    If doc.QUERY_STRING_DECODED(0)<>"" Then'it's a GET
        myQuerystring = doc.QUERY_STRING_DECODED(0)
    ElseIf doc.QUERY_STRING(0)<>"" Then
        myQuerystring = doc.QUERY_STRING(0)
        'decode it !
    ElseIf doc.REQUEST_CONTENT(0)<>"" Then'it's a POST
        myQuerystring = doc.REQUEST_CONTENT(0) ' WARNING this is for POST but you will have to decode !!!
        'decode it !
    Else
        logErrorEX "getting a call with document context but without query_string?!?","", doc,""
        GoTo returnErr
    End if
    Call ExplodeQueryString(myQuerystring, doc)
    
    Private Sub  ExplodeQueryString (QueryString As String,doc As NotesDocument )
    
    Dim ArgsList As Variant 
    
    ArgsList = Split (QueryString,  "&")
    If IsArray(ArgsList) Then 
        debugString = debugString+"ArgsList is an array of " & UBound(ArgsList) 
    Else
        debugString = debugString+"ArgsList is NOT an array ??? " & ArgsList
    End if
    Dim ArgKey As String
    Dim ArgValue As String
    ForAll Arg In ArgsList
        If left$(Arg, 1)= "_" Or Left$(Arg, 1)= "%" Then
            'ignore it      
        else 
            ArgKey = strleft(Arg, "=")
            If ArgKey = "" Then
                'ignore it?
            else
                ArgValue = strright$(Arg, "=")
                '               AgentArgs(ArgKey) = ArgValue
                doc.Replaceitemvalue ArgKey, ArgValue
            End If
        End if
    End ForAll
    End Sub
    

    I didn't declare some global variable like debugString to shorten in.