9 Replies Latest reply: Sep 29, 2016 3:29 PM by Alexander Karlsson RSS

    No response from OpenDoc method on desktop

    Michael Granillo

      Can someone tell me what's wrong with my code?

       

      I'm trying to communicate with the desktop engine using the opendoc method and the browser. 

       

      The getdoclist method works so i have a working connection.  I just don't know why i dont get a result for the OpenDoc method.

       

      <!doctype html>

      <!-- <html> -->

      <html>

      <head>

       

       

      <script src="https://rawgit.com/mindspank/qsocks/master/qsocks.bundle.js"></script>

      <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.js"></script>

      <script>

       

       

      function connect() {

        qsocks.Connect().then(global => {

        global.getDocList().then(function(documents) {

                var available_docs = [];

                documents.forEach(function(document_entry){

                  available_docs.push(document_entry.qDocId);

                });

         console.log(available_docs);

         });

        

           global.OpenDoc("H:\My Documents\Qlik\Sense\Apps\Consumer_Sales.qvf").then(function(app) {

        app.GetAllInfos().then(function(appInfos){

                    var measures_list = [];

                    appInfos.qInfos.forEach(function(document_infos){

                      if(document_infos.qType=='measures'){

                        measures_list.push(document_infos.qId) 

                      }

                    });

         console.log(measures_list.length());

        });

        });

         });

      }

       

       

      connect();

       

       

       

       

      </script>

      <body></body>

      </script>

      </head>

      <body>

      </body></html>

        • Re: No response from OpenDoc method on desktop
          Alexander Karlsson

          That looks fine but I'm guessing that the path is a mapped drive so maybe something gets messed up with UNC there.
          Have you tried inputting the full path and/or placing the file locally and try it that way?

           

           

          If you get stuck then feel free to join us on slack and ping me and we can take a look at it,

          http://qlikbranch-slack-invite.herokuapp.com/

            • Re: No response from OpenDoc method on desktop
              Michael Granillo

              Alexander,

               

              Thanks for the advice.  That path is a mapped drive but there's nothing I can do to change that.  It's our IT infrastructure here.  I've tried re-pointing the apps directory in the settings.ini file but this stopped working in Sense 3.0. 

               

              I've joined the slack channel.  What do you use this for? 

               

              Mike

                • Re: No response from OpenDoc method on desktop
                  Alexander Karlsson

                  Try putting the app the on C:\ drive as just do openDoc('C:\\app.qvf')

                    • Re: No response from OpenDoc method on desktop
                      Michael Granillo

                      I tried your suggestion but it didn't work.  I tried single slashes in the path and using just the app name but never received output in the console. 

                       

                       

                      2016-09-19 08_43_19-Developer Tools.jpg

                       

                      In case this helps, here's the Engine API Explorer output:

                      2016-09-19 08_57_54-Engine API Explorer _ Dev Hub.jpg

                        • Re: No response from OpenDoc method on desktop
                          Erik Wetterberg

                          Hi Michael,

                          Try encoding the pathname, either by hand(you can see what it should look like in Engine API explorer) or with encodeURIComponent.

                           

                          Let us know if this helps

                           

                          Erik

                          • Re: No response from OpenDoc method on desktop
                            Erik Wetterberg

                            Hi Mike,

                            I've payed around with this abit in node and can't really reproduce your problem. I suggest you make sure you catch your errors in all qSocks calls and see if you find something. BTW it is getAllInfos with a lowercase g, looks like qsocks is not quite consistent with upper/lowercase (Connect etc..).

                             

                            Another point to remember is that you can only open one app on a socket. To handle this I use qsocks.ConnectOpenApp (yes, it should be uppercase C), which will create one web socket for each app. This is also the way Engine API explorer works, and the way you are supposed to do it on server, since Qlik Sense load balancing needs the app id to be URL.

                             

                            My code looks like this:

                            const qsocks = require('../../qsocks');
                            const extend = require('util')._extend;
                            const Promise = require('promise');
                            
                            
                            const config = {
                                host: 'localhost',
                                port: 4848,
                                isSecure: false
                            };
                            
                            
                            function getAppObjects(appname) {
                                var cfg = extend({}, config);
                                cfg.appname = appname;
                                //open app on a new socket
                                return qsocks.ConnectOpenApp(cfg).then(function(result) {
                                    //result[0] will be global, result[1] will be the app
                                    var app = result[1];
                                    return app.getAllInfos().then(function(appInfos) {
                                        var objs = {};
                                        appInfos.qInfos.forEach(function(info) {
                                            if (!objs[info.qType]) {
                                                objs[info.qType] = [];
                                            }
                                            objs[info.qType].push(info.qId);
                                        });
                                        console.log("\nApp:\t", cfg.appname);
                                        for (p in objs) {
                                            console.log(p, ":\t", objs[p].join());
                                        }
                                    }).catch(function(err) {
                                        console.log("GetAllInfos failed", err);
                                    });
                                }).catch(function(err) {
                                    console.log("openDoc failed", err);
                                });
                            
                            
                            }
                            //Connect to QIX engine
                            qsocks.Connect(config).then(function(global) {
                                //fetch the app list
                                global.getDocList().then(function(docList) {
                                    var promises = [];
                                    docList.forEach(function(doc) {
                                        promises.push(getAppObjects(doc.qDocId));
                                    });
                                    //promises.push(getAppObjects("D:\\Ekonomi.qvf"));
                                    Promise.all(promises).then(function() {
                                        process.exit(0);
                                    });
                                });
                            }).catch(function(err) {
                                console.log("err", err);
                                process.exit(1);
                            });
                            

                             

                            It also available on github qsocks/list-local-apps.js at master · erikwett/qsocks · GitHub

                             

                            When I try this with an app that is not in MyDocuments\Qlik\Sense\Apps its not included in the app list, but you can open a socket to it anyhow.

                             

                            Hope this helps

                             

                            Erik

                    • Re: No response from OpenDoc method on desktop
                      Erik Wetterberg

                      Hi,

                      You should not need to give the full path if the app is in the default Apps directory, so you could try just 'Consumer_Sales.qvf'.

                       

                      If you do need the full path you might try with double backslash ("H:\\My Documents\\Qlik\\Sense\\Apps\\Consumer_Sales.qvf".

                       

                      BTW, is the Consumer_Sales app in the console output? What does it say?

                       

                      Hope this helps

                       

                      Erik