Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Partner
Partner

Triggering EDX using VB macro in Qlikview12.10

Hello All,

I am trying to let the user reload the dashboard thru IE plugin in Qlikview AccessPoint. My Qlikview version is 12.10 SR 5.

I have looked at several post on using VB script to trigger EDX task to reload QV for version 11 and older but I am having issues with setting the macro to run on my desktop version. I have created the EDX task and we do have the publisher license but I am getting an "Invalid Syntax" on the line xmlHttp.Send METHOD. Below is the vb code which I copied from other post.

Has anybody else faced this issue? Is there a better way to let the user reload the dashboard if I have the publisher.

Thanks in Advance,

'-----------------------------------------------------------------------------
'- EDX Global Constants
'-----------------------------------------------------------------------------
'

CONST USERNAME                  = ""  ' "domain\user"
CONST PASSWORD                  = ""    ' "password"
CONST EDXTASK                   = ""
CONST EDXPSWD                   = "!"
CONST QDS                       = ":4720/qtxs.asmx" 

'-----------------------------------------------------------------------------
'- EDX Global Variables
'-----------------------------------------------------------------------------
DIM xmlHttp  'Object used for connectivity to QDS
DIM xml   'Object container for XML response from QDS
DIM xmlObj  'Object container for XML response from QDS

DIM METHOD  'XML command string
DIM node  'counter used to iterate through XML response

Function GetTimeLimitedRequestKey()
    METHOD = "<Global method=""GetTimeLimitedRequestKey"" />"

    ' Submit request to the URL via HTTP
    xmlHttp.open "POST",QDS,false,USERNAME,PASSWORD
    xmlHttp.setRequestHeader "Content-Type","text/xml"
    xmlHttp.setRequestHeader "Content-Length", Len(METHOD)
    xmlHttp.Send METHOD

    ' Load the Response into an XML object
xml.async = false
xml.loadXML(xmlHttp.responseText)

set xmlObj = xml.SelectNodes("//GetTimeLimitedRequestKey")
for node = 0 to (xmlObj.length -1)
  if xmlObj.item(node).nodeName = "GetTimeLimitedRequestKey" then
  GetTimeLimitedRequestKey = xmlObj.item(node).text
  end if
next 'node

End Function

Sub RequestEDX
DIM TaskStartResult
set xmlHttp = CreateObject("Microsoft.XMLHTTP")
set xml = createobject("Microsoft.XMLDOM")
set xmlObj = createobject("Microsoft.XMLDOM")

METHOD = "<Global method=""RequestEDX"" key=""" & GetTimeLimitedRequestKey() &  """>"
METHOD = METHOD & "<i_TaskIDOrTaskName>" & EDXTASK & "</i_TaskIDOrTaskName>"
METHOD = METHOD & "<i_Password>" & EDXPSWD & "</i_Password>"
METHOD = METHOD & "<i_VariableName></i_VariableName><i_VariableValueList></i_VariableValueList>"
METHOD = METHOD & "</Global>"

' Submit request to the QDS via HTTP
xmlHttp.open "POST",QDS,false,USERNAME,PASSWORD
xmlHttp.setRequestHeader "Content-Type","text/xml"
xmlHttp.setRequestHeader "Content-Length", Len(METHOD)
xmlHttp.Send METHOD

select case xmlHttp.Status
    case 200:
        ' Load the Response into an XML object
        xml.async = false
        xml.loadXML(xmlHttp.responseText)

        ' Parse the XML Response extracting Status, Log, etc
        TaskStartResult = ""
        set xmlObj = xml.SelectNodes("//RequestEDX/RequestEDXResult/*")
        TaskStartResult = xmlObj.item(node).text
            select case TaskStartResult
             case "Success":
              ActiveDocument.GetApplication.MsgBox("Reload task successfully started. Document will refresh in ~X minutes.")
    case "TaskNotFound":
     ActiveDocument.GetApplication.MsgBox("Reload task not found")
    case "TaskIsAlreadyRunning":
     ActiveDocument.GetApplication.MsgBox("Reload task is already running")
    case else
     ActiveDocument.GetApplication.MsgBox("Reload task NOT started: unknown error")
   end select
    case 401:
        ActiveDocument.GetApplication.MsgBox("ERROR: The credentials for QDS (" & QDS & ") are incorrect.")
    case 403:
        ActiveDocument.GetApplication.MsgBox("ERROR: User is not authorised to request EDX tasks.")
    case 404:
        ActiveDocument.GetApplication.MsgBox("ERROR: The URL for QDS (" & QDS & ") is incorrect.")
    case 503:
        ActiveDocument.GetApplication.MsgBox("ERROR: The QDS (" & QDS & ") is unavailable.")
    case 12029:
        ActiveDocument.GetApplication.MsgBox("ERROR: The QDS (" & QDS & ") is not accessible.")
    case else
        ActiveDocument.GetApplication.MsgBox("ERROR: An error (" & xmlHttp.Status & ") occurred trying to access the QDS.")
end select 'xmlHttp
End Sub