0 Replies Latest reply: Aug 28, 2017 6:50 AM by Cheenu Janakiram RSS

    QlikSense: reload only during business hours - a 'quick and dirty' setup/workaround

    Cheenu Janakiram

      Hi everyone,

       

      I needed an option of running tasks on 15min-basis and hourly-basis only during business hours. However, it seems that the only option in QlikSense is to set one 'weekly' task for each execution, i.e. 4 tasks for each hour needed to run in the 15-min option and one task per hour for hourly run, for ALL tasks).

       

      Obviously, there had to be a better way around this and I thought about a functional, albeit 'unelegant' manner to quickly and easily configure this. Until Qlik rebuilds this option into Sense QMC (as in QlikVIew) or I become an Engine API expert (always think positive), I think this setup should work.

       

      Create and publish in a private stream an app with the following script:

       

      SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

       

      LET vSOBD = NUM(MakeTime(02,00));

      LET vCOB = NUM(MakeTime(21,30));

       

      IF (WeekDay(TODAY()) <> 'Sat' AND WeekDay(TODAY()) <> 'Sun') AND (FRAC(Time(NOW())) >= $(vSOBD) AND FRAC(Time(NOW())) <= $(vCOB)) THEN

      EXIT SCRIPT;

      ELSE

      LOAD FAIL FROM ERROR;

      END IF;

       

      This script takes one second to reload in both IF and ELSE scenarios. Reading from the script, it might have become obvious what I am trying to do and also why it is 'unelegant'.

       

      The vSOBD and vCOB variables are where you set business start hours and end hours and you can also change the day of run to Weekdays and exclude any specific day, e.g. in this case weekends.

       

      If it is during a business day and hour you have set, it will 'exit script'. If it isn't a business day and hour, it will fail. This is the 'unelegant' part, as I hate to see 'red' X on my QMC Tasks.

       

      However, you can quickly create tasks, which reloads every X hours or X mins and then attach all proper reloads on the 'successful completion' of the respective X-hours or X-mins task.

       

      Hope this helps whilst waiting for a true solution.

       

      Have fun,

       

      Cheenu