12 Replies Latest reply: Oct 13, 2015 8:41 AM by Yakir Manor RSS

    Question: How to Reload from the Accesspoint without Publisher

      I've searched both the web and this forum for a solution on how to reload data in a application from the accesspoint. No straight forward solution did I find so my question is how to set this up? It should not include the publisher and the best solution would be if it was implemented so the user pressed a button in the application to make the document reload.

        • Question: How to Reload from the Accesspoint without Publisher
          Magnus ÅVITSLAND

          Hi Ola.

           

          > Goto QMC/QEMC

          > Documents

          > User Documents

          > Browse to a document and choose reload schedule

           

           

          Kind regards

           

          Magnus Åvitsland

          BI Consultant

          Framsteg Business Intelligence Corp.

          • Re: Question: How to Reload from the Accesspoint without Publisher

            i was asking for the same function a while ago.

            At that time it was not possible in the current versions to reload data by using a button in the qv document which is displayed in the publisher.

             

            the only option was to use a .bat or VB file on the local machine.

            the file will start a remote execution on the server - not very safe if too many users have execution rights on the server.

             

            a complete reload takes some time too, so other users might be blocked from using the qv file while reloading.

            at the time, there was no option to start a partial reload from inside the .qvw by remote exec. only a bat file on the local machine.

             

            this might have changed by now

              • Question: How to Reload from the Accesspoint without Publisher

                Ok, and how could such a .bat file look like? Do you have any good examples?

                 

                When researching on a solution I found the application called PsExec which you could use to remoteley execute a application. In this case it would be the qlikview program with the /r for reload for the specific file. The commandline for running PsExec could then be included in a .bat file that the user executes on his local PC.

                  • Re: Question: How to Reload from the Accesspoint without Publisher

                    PsExec is one approach, but there is a built in Option since QV server v9 : EDX

                    PsExec needs FULL ADMIN RIGHTS on the Server, which should be avoided.

                     

                    You can find more information in the server reference manual, which may be installed with the server.

                    But as usual, the reference manual has no examples which actually lead to a solution.

                    But there is a short Description of EDX in generall:

                     

                    24 Triggering EDX Enabled Tasks   
                    To start tasks that have an external event as trigger, the QlikView Management Service API (QMS API) must be used.
                    The user making the request calls must be a member of the QlikView Administrators local group or the
                    QlikView EDX local group. The QlikView Administrators group is set up during the installation of
                    QlikView Server, but the QlikView EDX group must be created manually in Computer Management.

                    Members of the QlikView EDX group only have the right to trigger EDX-enabled tasks.

                     

                    The last part is crucial, because you dont want every user that can reload data (which should be limited anyway) to be an admin on your qv server.

                     

                    The Remote Calls have come a longe way since QV9. The EDX Capability of your server greatly depends on which version you are using.

                    My recent test (Server v11) showed that its now possible to reload by using a button (macro) in the .qvw.

                     

                     

                    File name startedx.bat

                    this file must contain for example:

                    C:\"Program Files"\QlikView\Qv.exe /NoSecurity C:\RUN_TASK_BY_EDX.qvw

                     

                    in RUN_TASK_BY_EDX.qvw in Document/properties/Triggers(Eventi) OnOpen (su apertura)  you set to run the macro "RunTask".

                     

                    You can find more Information in this threat:

                    http://community.qlik.com/thread/15988

                     

                    http://community.qlik.com/docs/DOC-2650Using EDX in QlikView 11 "Using EDX in QlikView 11"

                     

                    Here are only 2 Users here which have the right to reload Data by EDX.

                     

                    Before that, Users had the strange idea to reload "their" reports before the first use each day - while other users were allready using these.

                    now there is a "reload person" in each group who uses qv, which can be contacted to reload the data.

                    Also, there is a texbox on each Report, that shows (aditionally to the AccessPoint Information), when the file was reloaded with new data.

                    ='Last Reload:  '&ReloadTime()

                • Re: Question: How to Reload from the Accesspoint without Publisher

                  "the best solution would be if it was implemented so the user pressed a button in the application to make the document reload."

                   

                  RUN_TASK_BY_EDX.qvw does exactly this.

                   

                  If this solves your Problem, please mark the question as soved and the appropriate Answer as the Solution, so other users can find it.

                  If your problem is not solved by this suggestion, feel free to give feedback and ask for more help.

                  • Re: Question: How to Reload from the Accesspoint without Publisher
                    Yakir Manor

                    Hi,

                    this is for partial reload without the publisher

                    ill assume you know how to use the API,
                    it helps to search the 'QMS API Documentation', you can find it here -

                    QMS API Documentation - Version 11

                     

                    in the api if you search 'partial' you get 'TaskReloadMode Enumeration' so from that we understand there might be a chance (-:.

                     

                    lets look at 'C:\ProgramData\QlikTech\DistributionService\Tasks' there we can see the xml of all the tasks, and we can also find the task ID so we can delete the task or run it

                     

                    creating partial reload starting from a point where we have no tasks at all (you can have tasks but just for this example):

                    1. create the first task by going to: QMC -> Documents -> select the document we want to partial reload (development.qvw) -> Reload tab -> choose any: i did: Daily -> Apply

                    a file was created in the task folder with the name: 'Task_39614ba7-0628-4264-ac31-b553ba3a0862.xml'

                     

                    2. go to: Status -> Tasks -> verify a task was indeed created 'Reload of Development.qvw'

                     

                    3. open visual studio and run the following code: (some changes is needed to adjust for your file, here we want to apply it to 'Development.qvd')

                     

                    
                    // Initiate backend client
                    IQMS apiClient = new QMSClient();
                    
                    // Get a time limited service key
                    ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();
                    
                    // Get QlikView Server
                    ServiceInfo qds = apiClient.GetServices(ServiceTypes.QlikViewServer).FirstOrDefault();
                    DocumentNode document = apiClient.GetUserDocuments(qds.ID).Where(x => x.Name.Equals("Development.qvw", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); //Get first source document for this example
                    
                    
                    DocumentTask documentTask = new DocumentTask();
                    documentTask.QDSID = qds.ID;
                    documentTask.Document = document;
                    documentTask.Reload = new DocumentTask.TaskReload();
                    documentTask.Reload.Mode = TaskReloadMode.Partial;
                    
                    
                    documentTask.General = new DocumentTask.TaskGeneral();
                    documentTask.General.Enabled = true;
                    documentTask.General.TaskName = "Partial Reload of Development.qvw";
                    documentTask.General.TaskDescription = "Creating a task via QMS API";
                    documentTask.Scope = DocumentTaskScope.General;
                    
                    
                    Guid triggerID = Guid.NewGuid();
                    
                    
                    // Create a scheduled trigger
                    ScheduleTrigger st = new ScheduleTrigger();
                    st.ID = triggerID;
                    st.Type = TaskTriggerType.OnceTrigger;
                    st.Enabled = true;
                    st.StartAt = DateTime.Now;
                    
                    
                    // Create a list of trigger and add the scheduled trigger
                    List<Trigger> List_Trigger = new List<Trigger>();
                    List_Trigger.Add(st);
                    
                    
                    documentTask.Triggering = new DocumentTask.TaskTriggering();
                    documentTask.Triggering.Triggers = List_Trigger;
                    
                    
                    documentTask.Triggering.TaskDependencies = new List<TaskInfo>();
                    documentTask.Triggering.ExecutionAttempts = 1;
                    documentTask.Triggering.ExecutionTimeout = 360;
                    
                    
                    // Scope plays an important role
                    documentTask.Scope = DocumentTaskScope.General | DocumentTaskScope.Triggering | DocumentTaskScope.Reload;
                    
                    
                    //Create task
                    apiClient.SaveDocumentTask(documentTask);
                    
                    
                    
                    

                     

                    4. see the task 'Partial Reload of Development.qvw' was created, try running it - NOTHING HAPPENS!, how do we know, because we opened the 'Development.qvw' file in the qlikview client and did Settings -> Document Settings -> General tab -> Generate Logfile & Timestamp in Logfile Name, and no log file was created )-:, now lets run the the 'Reload of Development.qvw', we can see a log file was created,

                    also a new file was created in tasks 'Task_6c92c573-a395-47e2-8e75-a15f0d128b46.xml'.

                     

                    5. now here is where the magic happens:

                    a. open both tasks xmls in notepad++ (from 'C:\ProgramData\QlikTech\DistributionService\Tasks')

                    b. make sure you opened notepad++ using 'run as administrator'

                    c. now copy all the data from 'Reload of Development'  ('Task_39614ba7-0628-4264-ac31-b553ba3a0862.xml' if we open both xmls the names are inside) to the 'Partial Reload of Development.qvw' ('Task_6c92c573-a395-47e2-8e75-a15f0d128b46.xml') and save the file EXCEPT 'DistributeTask' open node, so basically all the lines except the first two.

                    d. restart the 'QlikView Distribution Service' from Start -> Administrative Tools -> Services

                    e. now run the the task - VOILÀ the task is running!, problem is, its doing a full reload )-:

                    f. open the xml again of the 'Partial Reload of Development.qvw' search for 'LoadType' in the 'SourceDocument' node and change it to 'PartialReload', restart the 'QlikView Distribution Service' again, run the task from the qmc.

                    g. if you dont want the trigger in the xml you can remove it otherwise the partial task will run with the trigger settings, this is the line:

                     

                    <ScheduleTrigger ID="0afcc688-06c2-4925-93ac-d153a298cb5d" Enabled="True" EnableDateTime="2014-01-01 00:00:00Z" ExpireDateTime="9999-12-31 23:59:59Z" RecurrenceType="RecurrenceDaily" RepeatEvery="1" HourStart="2014-01-01 02:00:00Z" DayStart="0" RepeatMaxCount="0" />
                    
                    
                    

                     

                    that's it! you have partial reload

                     

                    you might want to delete some tasks, copy the task ID (name of task is inside the file) and run the code:

                     

                    IList<TaskInfo> taskList, docTaskList;
                    List<string> taskstoremove = new List<string>();
                    taskstoremove.Add("6c92c573-a395-47e2-8e75-a15f0d128b46");
                    foreach (var item in taskstoremove)
                    {
                        try
                        {
                            var taskID = new Guid(item);
                            var task = apiClient.GetTask(taskID);
                            apiClient.DeleteTask(taskID, TaskType.DocumentTask);
                        }
                        catch (System.Exception ex)
                        {
                            response.Append(ex.Message);
                        }
                    }
                    
                    
                    

                     

                    you might want to run the task, this is no problem, create any app, console app or .net app what ever you want and run the code:

                     

                    apiClient.RunTask(new Guid("6c92c573-a395-47e2-8e75-a15f0d128b46"));
                    
                    
                    

                     

                     

                    CAUTION! CAUTION! CAUTION!

                     

                    do not delete any of the xml's (from 'C:\ProgramData\QlikTech\DistributionService\Tasks') deleting them without first delete them from code using 'DeleteTask' will crush 'QlikView Distribution Service' on restart and you wont be able to start the service again after stopping it!!!

                     

                    hope this helped!.

                     

                    im not sure this is the only solution, we don't have the Publisher licence so there might be other solutions using the publisher.

                    im not sure what happens if you delete the original task the 'Reload of Development.qvd' im too lazy to test it

                     

                    P.S.:
                    for some reason i just cant get any of the api methods to return all tasks,

                    iv tried the api apiClient.GetTasks and the apiClient.GetTasksForDocument while looping over all docs, nothing worked.

                     

                    maybe it's because we don't have publisher, finally iv found a work around:

                     

                    // Initiate backend client
                    IQMS apiClient = new QMSClient();
                    
                    
                    // Get QlikView Server
                    ServiceKeyClientMessageInspector.ServiceKey = apiClient.GetTimeLimitedServiceKey();
                    
                    
                    var serviceList = apiClient.GetServices(ServiceTypes.QlikViewServer);
                    
                    
                    List<TaskInfo> taskInfoList = new List<TaskInfo>();
                    TaskStatusFilter taskStatusFilter = new TaskStatusFilter();
                    taskStatusFilter.TaskStatuses = new List<TaskStatusValue>();
                    taskStatusFilter.TaskStatuses.Add(TaskStatusValue.Aborting);
                    taskStatusFilter.TaskStatuses.Add(TaskStatusValue.Completed);
                    taskStatusFilter.TaskStatuses.Add(TaskStatusValue.Failed);
                    taskStatusFilter.TaskStatuses.Add(TaskStatusValue.Running);
                    taskStatusFilter.TaskStatuses.Add(TaskStatusValue.Waiting);
                    taskStatusFilter.TaskStatuses.Add(TaskStatusValue.Warning);
                    List<TaskStatus> taskStatuses = apiClient.GetTaskStatuses(taskStatusFilter, TaskStatusScope.Extended); // A service call.
                    foreach (var taskStatus in taskStatuses)
                    {
                        taskInfoList.Add(apiClient.GetTask(taskStatus.TaskID));
                    }
                    
                    
                    

                     

                    from here you can easily run task by name or what ever. (-:
                    iv attached the project solution and the xmls.

                     

                    a good way to run the code is to create a console application (EXE) and run it with button macro that runs that application, in this example i compiled a small program that runs the partial reload, it searches for task with the name 'partial' on the 'development' document.


                    Sub ScriptPartialReload
                      set v = ActiveDocument.GetVariable("vLastPartialReloadAttempt")
                      v.SetContent now(),true
                      rem msgbox("Partial")
                      set v = ActiveDocument.GetVariable("vFileName")
                      vFile = v.GetContent.String
                        Platform = ActiveDocument.Evaluate("ClientPlatform()")
                        if isnull(Platform) or Len(Platform)=0 then
                      ActiveDocument.PartialReload
                        else
                      Set shell = CreateObject("WScript.Shell")
                      shell.Run "C:\QlikViewTasks\qv-user-manager.exe -t partial -d " + vFile
                        end if
                    End Sub
                    
                    
                    

                     

                    this will only work if you enabling the Allow macro execution on server and Allow unsafe macro execution on server on your Qlikview Server Managment Console.


                    Go to System->Setup->Qlikview Servers->Security tab.

                     

                    you might also need to enable macros in the document

                    Go to Tools -> Edit Module -> Requested Module Security: System Access, Current Local Security: Allow System Access

                     

                    the final result is:

                    Capture.PNG

                    adding in the end of the load script this part unable you to create a smart behavior for the reload button

                     

                    IF(IsPartialReload()) THEN
                      LET vLastPartialReload = Now();
                    ELSE
                      LET vLastReload = Now();
                    ENDIF
                    
                    
                    

                     

                    in the reload button properties in 'Enable Condition' write

                     

                    =Interval(vLastPartialReload - vLastPartialReloadAttempt, 'ss') > 0
                    
                    
                    

                     

                    and now the button will be disabled until the end of the reload process.

                     

                    Please

                    If you found it helpful (-:.