4 Replies Latest reply: Mar 29, 2012 5:36 AM by Dan-Ketil Jakobsen RSS

    EDX with delay

    Dan-Ketil Jakobsen

      Hi all.


      I have several EDX solutions up and running.

      Works like a charm.

      When I hit the button it uses about 10 seconds to do the reload.

      During this period I want the relevant tables and graphs to be hidden, and only to appear when the new result is being loaded.


      I have created a variable called vShow, it is default set to 0.

      When the user hits the button it is set to 1.


      My tables have a conditional layout that says vShow = 1


      Obivously the button will set the vShow to 1 as soon as I hit it. Thus showing the tables and graphs premature.


      Any idea on how to create a delay or make it show when the result from the load is done?



      Thanks in advance




        • EDX with delay

          I have done a similar thing with you.


          I have a text object which will show 'Reloading....' during reload process.


          The text object is shown conditionally when variable, vShown = 0.


          For the button, which trigger the EDX, add a action to change the vShown = 0.

          In the loading script, add

          let vShown = 1


          at the last line of the script.

            • EDX with delay
              Dan-Ketil Jakobsen

              I assumed that would be one solution, but I have not been able to figure out where in the script I should place the line.


              Here is my code:


              'Macro for EDX


              Sub TriggerEDX()


              Dim objHttp

              Dim strUrl

              Dim strData

              Dim strKeyRequest

              Dim strKeyAwnser

              'Dim varSQL

              Dim stringSQL

              Dim vShow



              SET varSQL = ActiveDocument.Variables("vSQL")'.GetContent.STRING

              'stringSQL = varSQL.GetContent.String




                  'Task Name from QEMC

                  Dim strTaskName

                  strTaskName = "EDX"


                  Dim strTaskPassword

                  strTaskPassword = inputbox("Please enter task password")


                  ' Create a HTTP instance

                  Set objHttp = CreateObject("Microsoft.XMLHTTP")


                  strUrl = "http://localhost:4720/qtxs.asmx"


                  'Get key for HTTP call

                  strKeyRequest ="<Global method=""GetTimeLimitedRequestKey"" />"


                  'Do HTTP call to server

                  objHttp.open "POST",strUrl,false

                  objHttp.setRequestHeader "Content-Type","text/xml"

                  objHttp.setRequestHeader "Content-Length", Len(strKeyRequest)

                  objHttp.Send strKeyRequest


                  'Parse the awnser

                  'Store reply from HTTP

                  Dim strKey

                  strKey = ParseKeyAwnser(objHttp.ResponseText)


                  'Get the string to send in the request that triggers the task

                  Dim strEDXRequest


                  'Store the result

                  strEDXRequest = GetEDXRequestString(strKey,strTaskName,strTaskPassword,varSQL.GetContent.String)


                  'Do the actual request to trigger the task

                  objHttp.open "POST",strUrl,false

                  objHttp.setRequestHeader "Content-Type","text/xml"

                  objHttp.setRequestHeader "Content-Length", Len(strKeyRequest)

                  objHttp.Send strEDXRequest


                  'Get the awnser, the awnser can contain different things but for now I only care to see if we find success

                  dim strAwnser

                  strAwnser = objHttp.ResponseText


                  'The awnser if success looks like this


                  '  <RequestEDXResult>

                  '    <TaskStartResult>Success</TaskStartResult>

                  '    <Log />

                  '  </RequestEDXResult>



                  if(Instr(strAwnser,"<TaskStartResult>Success</TaskStartResult>") > 0) then

                      msgbox("Loading data! This may take a few seconds!")



                  end if


              End Sub


              Function ParseKeyAwnser(strKeyAwnser)

              'The Awnser should look something like this


              '  <GetTimeLimitedRequestKeyResult></GetTimeLimitedRequestKeyResult>



              Dim intStartPos

              Dim IntKeyLen


              'Get the starting and the end position of the key

              intStartPos = InStr(strKeyAwnser,"<GetTimeLimitedRequestKeyResult>")+Len("<GetTimeLimitedRequestKeyResult>")

              intKeyLen = InStrRev(strKeyAwnser,"</GetTimeLimitedRequestKeyResult>") - intStartPos


              'Get and return the key

              ParseKeyAwnser = Mid(strKeyAwnser,intStartPos,intKeyLen)


              End Function


              Function GetEDXRequestString(strRequestKey,strTaskName,strTaskPassword,stringSQL)

              'The request to send look like this

              '<Global method="RequestEDX" key="RJtp/">



                '<i_VariableName /><i_VariableName />

                '<i_VariableValueList /><i_VariableValueList />



              'Make the string and insert the key

              GetEDXRequestString = "<Global method=""RequestEDX"" key=""" & strRequestKey &  """><i_TaskIDOrTaskName>" & strTaskName & "</i_TaskIDOrTaskName><i_Password>" & strTaskPassword & "</i_Password><i_VariableName >vSQL</i_VariableName ><i_VariableValueList ><string>" & stringSQL & "</string></i_VariableValueList ></Global>"


              End Function