Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Jason1
Contributor III
Contributor III

Delete File operation not working in Sense

I am using the below code to delete a file on a server if it is present. This exact code works in View but not in Sense. I have enabled Legacy Mode in Sense, so that doesn't seem to be the issue:

SET vQvdFile = '\\Server1\QlikView\Operations\Master\Loader\QVD\Embrace$(vCurrentYear)Q$(vCurrentQuarter).qvd';

TRACE $(vQvdFile);

LET vFileDeleted = (DeleteFile('$(vQvdFile)') = -1);
// 0 = false
// -1 = true
TRACE File deleted $(vFileDeleted) : -1 = true, 0 = false;

At design time, Sense highlights the open bracket after "DeleteFile" in red and underlines it. During runtime the following error message shows:

The following error occurred:
Unexpected token: '(', expected one of: ')', ':', 'OPERATOR_PLUS', 'OPERATOR_MINUS', 'OPERATOR_MULTIPLICATION', 'OPERATOR_DIVISION', 'OPERATOR_STRING_CONCAT', ...
The error occurred here:
LET vFileDeleted = (DeleteFile>>>>>>(<<<<<<'\\Server1\QlikView\Operations\Master\Loader\QVD\TESTING\Embrace2022Q2.qvd') = -1)

Any help would be appreciated as I am not sure how to interpret this error.

Thanks

J

 

 

Labels (1)
1 Solution

Accepted Solutions
Or
MVP
MVP

To the best extent of my knowledge, there is no DeleteFile() function in Qlik (Sense or View). Is this perhaps a customized VBscript function you created in QV?

If you want to delete a file from script in QS, I believe you need to execute an operating system command, e.g.

Execute cmd.exe /C del "FileName.qvd";

See: https://community.qlik.com/t5/App-Development/How-to-delete-QVD-file-for-load-script-in-Qlik-Sense/t...

 

View solution in original post

2 Replies
Or
MVP
MVP

To the best extent of my knowledge, there is no DeleteFile() function in Qlik (Sense or View). Is this perhaps a customized VBscript function you created in QV?

If you want to delete a file from script in QS, I believe you need to execute an operating system command, e.g.

Execute cmd.exe /C del "FileName.qvd";

See: https://community.qlik.com/t5/App-Development/How-to-delete-QVD-file-for-load-script-in-Qlik-Sense/t...

 

Jason1
Contributor III
Contributor III
Author

It works indeed. I can even put $() variables into the filename string:

Execute cmd.exe /C del "\\WNLBI01\QlikView\Operations\Master\Loader\QVD\TESTING\Embrace$(vCurrentYear)Q$(vCurrentQuarter).qvd";

 

Thanks for the assistance!

J