1 Reply Latest reply: Oct 13, 2015 8:43 AM by Yakir Manor RSS

    'How to create a task with PARTIAL Reload' using QMS API?

      Hi Team, GM.


      Could you please help me with an sample 'How to create a task with PARTIAL Reload' using QMS API? and 'How to specify Distribution Folder Path for it? I have looked over and over in API documentations and community forum but failed to get any snipts. It would be great if you share a working code sample or direction to a clear document source. advacne [Thumbs Up].




        • Re: 'How to create a task with PARTIAL Reload' using QMS API?
          Yakir Manor


          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>();
          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


          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>();
          foreach (var item in taskstoremove)
                  var taskID = new Guid(item);
                  var task = apiClient.GetTask(taskID);
                  apiClient.DeleteTask(taskID, TaskType.DocumentTask);
              catch (System.Exception ex)


          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"));





          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


          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>();
          List<TaskStatus> taskStatuses = apiClient.GetTaskStatuses(taskStatusFilter, TaskStatusScope.Extended); // A service call.
          foreach (var taskStatus in taskStatuses)


          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
            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:


          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();
            LET vLastReload = Now();


          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.



          If you found it helpful (-:.