4 Replies Latest reply: Aug 23, 2018 7:59 PM by Jared Church RSS

    QSense: How to get the current stream name

    ULISES YAIR OGAZ

      Hi everybody! 

      Is there any function or instruction that retrive the current stream name that is running the Qsense application on the server?

       

      I developed an application “DATA_Mayuda” in the hub server. The application connects to a database. Then read a table, generate a QVD, and finally drop the table. All that works well.

       

       

      LIB CONNECT TO 'Mesa de Ayuda QA';

      WorkOrder:

      SQL SELECT * FROM servicedesk.workorder;

      STORE WorkOrder into [lib://QlikShared/_Test\Mesa de Ayuda\QVD\workorder.qvd];

      Drop Table WorkOrder;

       

       

       

      Now, I need to store the QVD file according to the current stream. But I don´t know how to resolve it.

       

       

      LIB CONNECT TO 'Mesa de Ayuda QA';

      WorkOrder:

      SQL SELECT * FROM servicedesk.workorder;

      -- FunctionThatRetriveCurrentStream (vCurrentStream); ?????

      If vCurrentStream = “Testing” then

             STORE WorkOrder into [lib://QlikShared/_Test\Mesa de Ayuda\QVD\workorder.qvd];

      Else

              STORE WorkOrder into [lib://QlikShared/_Production\Mesa de Ayuda\QVD\workorder.qvd];

      End if

      Drop Table WorkOrder;

       

       

      Thanks in advanced.

       

       

      Ulises Yair Ogaz | Analista Técnico/Desarrollador JDE - SISTEMAS

        Laboratorios Casasco S.A.I.C.

       

       

        • Re: QSense: How to get the current stream name
          Peter Cammaert

          You posted a Qlik Sense question in a forum called "QlikView App Development". Please move your question to an appropriate Qlik Sense forum by following the steps specified here: QlikCommunity Tip: How to move your discussion thread

           

          Thanks.

          • Re: QSense: How to get the current stream name
            Felip Drechsler

            Hi Ulises,

             

            There's no function to get the stream of an app in the script side.

            For what you want, you could do two apps differentiating between Test and Prod environment.

            Would be the same code, but with different stores.

             

            - Test env

            LIB CONNECT TO 'Mesa de Ayuda QA';

             

            WorkOrder:

            SQL SELECT * FROM servicedesk.workorder;

             


            STORE WorkOrder into [lib://QlikShared/_Test\Mesa de Ayuda\QVD\workorder.qvd];

             

             

             

            Drop Table WorkOrder;


            - Prod env

            LIB CONNECT TO 'Mesa de Ayuda QA';

             

            WorkOrder:

            SQL SELECT * FROM servicedesk.workorder;

             


            STORE WorkOrder into [lib://QlikShared/_Production\Mesa de Ayuda\QVD\workorder.qvd];

             

             

             

            Drop Table WorkOrder;

            • Re: QSense: How to get the current stream name
              Jared Church

              You can do this using the Qlik monitoring connector:

               

              Here is the function I've done this morning (based on the load script in the Operations Monitoring app) to do exactly the same issue you're looking at.

               

              The function is based on the load script from the Operations Monitoring App:

              https://help.qlik.com/en-US/sense/June2018/Subsystems/Monitoring/Content/OperationsMonitor/Operations-monitor-app.htm

               

              You pass the ObjectID of the app you care about (you can get that using function: DocumentName())  and when the function completes the global variable 'vReturn' will hold either the Stream name or 'Unpublished'.

               

               

               

              SUB fGetAppStream(id)

               

                LIB CONNECT TO 'monitor_apps_REST_app';

               

                RestConnectorMasterTable:

                SQL SELECT

                    "id" AS "id_u4",

                    "name" AS "name_u3",

                    "published",

                    "__KEY_root",

                    (SELECT

                        "name" AS "name_u2",

                        "__FK_stream"

                    FROM "stream" FK "__FK_stream")

                FROM JSON (wrap on) "root" PK "__KEY_root";

               

              //   LET NumRows_monitor_apps_REST_app = NoOfRows('RestConnectorMasterTable');

               

                map_stream:

                Mapping LOAD

                    [__FK_stream] AS [__KEY_root],

                    [name_u2] AS Stream

                RESIDENT RestConnectorMasterTable

                WHERE NOT IsNull([__FK_stream]);

               

                App_Stream:

                LOAD

                    [id_u4] AS ObjectId,

                    name_u3 as [App Name],

                    ApplyMap('map_stream',__KEY_root,'Unpublished') as [App_Stream]

                RESIDENT RestConnectorMasterTable

                WHERE NOT IsNull([__KEY_root])

              and id_u4='$(id)';

              ;


                DROP TABLE RestConnectorMasterTable;


              if NoOfRows(App_Stream) <> 1 then

              trace ERROR;

                      set vReturn='Unpublished';

                  else

              let vReturn = peek('App_Stream','0','App_Stream');

                  end if;



                drop table App_Stream;

              ENDSUB