Parker Software Ltd Homepage
Forum Home Forum Home > WhosOn Live Chat > FAQ's > Advanced FAQ's
  New Posts New Posts RSS Feed - Parse Chat Survey Data (Script)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Parse Chat Survey Data (Script)

 Post Reply Post Reply
Daniel Horton View Drop Down
Admin Group
Admin Group
Technical Support

Joined: 01 Jun 2009
Location: Stoke-on-Trent
Points: 351
Post Options Post Options   Thanks (0) Thanks(0)   Quote Daniel Horton Quote  Post ReplyReply Direct Link To This Post Topic: Parse Chat Survey Data (Script)
    Posted: 08 Dec 2014 at 6:51pm
When using the ThisChatSession.PreChatSurvey value within script, you will need to parse the data so that you can use the extracted values within a potential script, such as a Pre-Chat Survey Script. The below is a function that has been created, where all you need to do if give the function your survey's field name from when you created the field.
The format of ThisChatSession is  "<field><name>Field1</name><value>Value1</value></field>"

ExtractFullTag([XML data],[value])

SurveyValue = ExtractFullTag(ThisChatSession.PreChatSurvey ,"Field1")

The return would be Value1. 

ExtractFullTag Function:
Private Function ExtractFullTag(ByRef data As String, ByVal TagName As String) As String
Dim STag As Long
Dim ETag As Long
Dim TLen As Long
Dim LCData As String

    On Error GoTo extErr
    TagName = LCase$(TagName)
    LCData = LCase$(data)
    STag = InStr(LCData, "<name>" & TagName)

    If STag > 0 Then
        STag = InStr(STag, LCData, "</name>") + 14
        ETag = InStr(STag, LCData, "</value>")
        If ETag > STag Then
            TLen = ETag - STag
            ExtractFullTag = Mid(LCData, STag, TLen)
            ExtractFullTag = ""
        End If
        ExtractFullTag = ""
    End If
    Exit Function
    ExtractFullTag = ""
End Function
Best Regards,

Daniel James Horton

Technical Manager

Parker Software
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.05
Copyright ©2001-2016 Web Wiz Ltd.

This page was generated in 0.203 seconds.