14 Replies Latest reply: Oct 23, 2017 9:49 AM by Peterjohn Griffiths RSS

    QvWorkPath and DocumentPath not updating.

    Peterjohn Griffiths

      Hi all,

      I have been trying to figure this one out but can't seem to find out why these variable are not correct.

      I assign the values of the variables (QvWorkPath and DocumentPath) and use them within my script, but they do not relate to the current location of the document but the development location.

      From what I can see they should reflect the documents current location.

      Has anyone got any idea how I can find out the current location of the QVW file that is being executed.

      Many thanks.

        • Re: QvWorkPath and DocumentPath not updating.
          Tresesco B

          Filepath()

           

           

           

          Load

                    *,

                    filepath( ) as X

          from C:\UserFiles\abc.txt;


          Will return 'C:\UserFiles\abc.txt' in field X in each record read.

          • Re: QvWorkPath and DocumentPath not updating.
            Kwok Chong

            These are system defined variables and cannot be changed. If you like to work with different paths, you'll have to define your own variables.

            • Re: QvWorkPath and DocumentPath not updating.
              Kwok Chong

              Having re-read your post a little bit more, have you reloaded the document in the "current" location? These variables are set when the document is refreshed and may still hold the values of the previous environment.

                • Re: QvWorkPath and DocumentPath not updating.
                  Peterjohn Griffiths

                  Hi Kwok Chong,

                  I may not of been clear about this, sorry, but yes I am running the document on the Qlikview server and this updates the QVW but the paths used are the development paths, not the location of the QVW.

                  I am setting the variables manually as a workaround but then this script is no longer dynamic and makes for a maintenance nightmare.

                  It seems to me that these variables do not do what they should, update when the script is first executed.

                    • Re: QvWorkPath and DocumentPath not updating.
                      Tresesco B

                      If you run reload at one place and place the qvw into another path, this could be a problem using the system path variables. You could possibly use Relative Path and perhaps an organised folder structure. Refer this nice post by Steve Dark : http://www.quickintelligence.co.uk/qlikview-folder-structures/

                      • Re: QvWorkPath and DocumentPath not updating.
                        Peterjohn Griffiths

                        OK, I think I have this figured out.

                        Further testing:

                        If I copy the values of QvWorkPath and DocumentPath into my own variables, I can then show the values of both of these when the script was running.

                        If I reload in the new destination, my own variables show that QvWorkPath and DocumentPath are the old development path when the script was running, so if used in the reload, old paths are used, however if I display QvWorkPath and DocumentPath in a text box after the reload, they show the new correct path.

                        If I reload a second time, all the variables are correct.

                        This shows that QvWorkPath and DocumentPath are only updated after the load script has finished running and this is what is causing the problem.

                         

                        Edit: It is also worth noting that DocumentName works fine and is updated before the load script runs. Very strange.

                          • Re: QvWorkPath and DocumentPath not updating.
                            Tresesco B

                            Have you changed the qvw name and checked? With me, it doesn't return the right name post change in name and before reload and this is what is documented in the help/manual.

                              • Re: QvWorkPath and DocumentPath not updating.
                                Peterjohn Griffiths

                                For me, if I change the file name and path, the variable QvWorkPath does not update until after a reload, so if I use QvWorkPath in the script it does not reflect the new location until after the reload.

                                If I use DocumentName, this is up to date straight away when opened on the client or the server location after changing the name and path.

                                Further testing seems to show that DocumentPath is also updating when opened on the client and the server at the moment and this may of been an error in my testing.

                                So, I am going to try using DocumentPath and DocumentName instead of QvWorkPath and see how that goes.

                        • Re: QvWorkPath and DocumentPath not updating.
                          Kevin Pickering

                          This post is probably dead, but thought I'd give my code.

                           

                          I'm trying to achieve exactly what Peterjohn is trying to achieve and yes system variable QvWorkPath is only good after the first reload has been done. The first reload will give incorrect location if the document has been moved since the last reload.

                           

                          I've written the following script which uses dos cmd to echo current directory to a file, it then read in the contents of the file for processing in qlikview... Further string manipulation looking for Development, Test or Production will give the environment you're running the load script in.

                           

                          SUB vL.WorkingPath
                          LET vL.DirectoryFile = 'Directory_' & NUM(NOW()) & '.txt';
                          EXECUTE cmd.exe /c "echo %CD% >> $(vL.DirectoryFile)";
                          Directory:
                          LOAD
                            TRIM(@1) AS Directory
                          FROM
                            [$(vL.DirectoryFile)] (txt, codepage is 1252, no labels, delimiter is '\t', msq);
                          LET vL.WorkingPath = PEEK('Directory', 0, 'Directory') & '\';
                          DROP TABLE Directory;
                          EXECUTE cmd.exe /c "del $(vL.DirectoryFile)";
                          END SUB

                          CALL vL.WorkingPath;

                            • Re: QvWorkPath and DocumentPath not updating.
                              Peterjohn Griffiths

                              It may not be clear from the other posts, but relative paths resolved the problem for me.

                              Here is the code I use.

                               

                              LET vPathFilename_Qvw = '.\' & DocumentName(); //Create a relative path to the filename of this QVW dashboard.

                               

                              I then modify the path to give me a AuditLog filename in the same path as the QVW file by doing the following.

                               

                              LET vPathFilename_AuditLog = replace(vPathFilename_Qvw, '.qvw', '_AuditLog.QVD'); //Filename of the AuditLog should be the same as vPathFilename_Qvw but with _AuditLog before .qvw

                               

                              I then use the variable vPathFilename_AuditLog for the location of the file.

                              This works great for me.

                              Hope it helps.