thanks for your time.
filepath() gives the path to the data file being loaded within a load statement.
The help file says:
Returns a string containing the full path to the table file currently being read.
I am after the path to the QVW document being executed.
From what I have read (QvWorkPath and DocumentPath) should be the variables used for this, but they don't work correctly all the time as they seem to keep the development path.
The Help file says the following.
Returns a string containing the full path to the current QlikView document.
However when I test this by developing a document on our network drive it outputs the network path correctly.
When this is copied and runs from our server, it still shows the development network path instead of the execution C drive path of the QVW file being executed.
This is unexpected and is not the path to the file that I need when the script is executed.
I get the same with vWorkPath. The felp file says the following
Returns the browse string to the current QlikView document. A system-defined variable
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.
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/
OK, I think I have this figured out.
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.
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.
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.
LET vL.DirectoryFile = 'Directory_' & NUM(NOW()) & '.txt';
EXECUTE cmd.exe /c "echo %CD% >> $(vL.DirectoryFile)";
TRIM(@1) AS Directory
[$(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)";
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.