Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
pgriffiths
Creator
Creator

QvWorkPath and DocumentPath not updating.

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.

14 Replies
pgriffiths
Creator
Creator
Author

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.

tresesco
MVP
MVP

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.

pgriffiths
Creator
Creator
Author

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.

kevpickering
Contributor III
Contributor III

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;

pgriffiths
Creator
Creator
Author

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.