Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sunny_talwar

Export Scripts from multiple QVW files

Hi all - 

Is there a quick way to export the scripts from multiple files? I know to export them one by one by going to the edit script and then exporting it out. Can this be done programmatically for multiple qvws so that we don't have to be export them one by one?

To give a brief background, I am looking for a SQL query that might be running in one of the 100-150 qvw files that we have and although I have looked through the log file, I have seen that not all SQL queries are logged into the log file. If I were to export the log files from all the dashboards, I can very easily use NotePad++ to look through them to find the keywords from the query.

Now that you know what I am trying to do, may be there is another efficient way to find out what I am looking for? I am open for suggestions.

@rwunderlich@marcus_sommer

Thanks,
Sunny

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

I don't know how you all missed the tool:

Qlikview Cookbook: Script Repository http://qlikviewcookbook.com/recipes/download-info/script-repository/

The Script Repository tool will extract the script from an entire set(s) of QVWs and give you a search UI as well.

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

P.S. If you came to a recent Masters Summit you would know all about this stuff 🙂

View solution in original post

17 Replies
m_woolf
Master II
Master II

This post:

https://community.qlik.com/t5/QlikView-Scripting/export-script-into-txt-file/m-p/1393371

has a macro that exports the current application's script to a text file.  With some adjustment, you might make it loop through all qvws and export the script.

sunny_talwar
Author

I will take a look at it. Thanks
prieper
Master II
Master II

Which SQL-queries are not in the logfiles?
I used to have one QVW, which reads all logfiles and highlights certain keywords. Thus you have all data in one place.
sunny_talwar
Author

@stevedark would you be able to help here since you have had worked with similar situation in the past based on this thread

Code to export script

sunny_talwar
Author


@prieper wrote:
Which SQL-queries are not in the logfiles?

I have not been able to determine the pattern, but I have seen that not all sql queries show up on the log file... I used to think that if you add SQL in front of your SELECT, it will not show up on the log file. But I am not sure this is true. But to be truthful, I have not done enough testing around this.


@prieper wrote:
I used to have one QVW, which reads all logfiles and highlights certain keywords. Thus you have all data in one place.

I have been able to go through the logfiles using NotePad++ to look for the keywords, so loading the logfiles into QlikView might not really help me here. What I really need is to look at each of the script.

marcus_sommer

Here a similar one which looped through the cells of a tablebox to read the path and filenames (you might create this table with a dirlist/filelist-loop within the script):

sub ReadScript

dim doc, obj, prop, newApp, newdoc, fso, File, FilePath, iRow, app, path, script

set doc = ActiveDocument
set obj = doc.GetSheetObject("TB04")

FilePath = ActiveDocument.Variables("pApp@01").GetContent.String
FilePath = FilePath & "DataStructures\"

for iRow = 1 to obj.GetRowCount - 1 
	set app = obj.GetCell(iRow, 0) 
	set path = obj.GetCell(iRow, 1) 
	set newApp = ActiveDocument.GetApplication 
	set newdoc = newApp.OpenDoc (path.Text & "\" & app.Text,"","") 
	set prop = newdoc.GetProperties 
	script = prop.Script 
	set fso = CreateObject("Scripting.FileSystemObject") 
	set File = fso.OpenTextFile(FilePath & "LoadScript_" & app.Text & typ, 2, true)		File.Writeline script
	File.Close 
        newdoc.closedoc  
next

end sub 

Instead of OpenDoc you might choose OpenDocEx which has a parameter to open an application with no data.

Alternatives to this might be to use prj-folder or (to macro-export also within a loop) the document-layout and reading then the script from there. Each way will have some benefits and disadvantages.

- Marcus

marcus_sommer

I just remembered that there is already a very useful tool for it: qlikviewcookbook.com - script-log-analyzer

- Marcus

marcus_sommer

Maybe the SQL queries aren't logged if there happens any error. Therefore using the ERRORMODE especially with the ScriptErrorDetails which contain detailed infos about the database-errors might give useful hints for your issues.

- Marcus

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

The Script Analyzer by @rwunderlich is an excellent too, as @marcus_sommer suggests.

If you want something a bit more automated, you could look at setting up project folders for all of your QVW files. On any change the script (and all object definitions) are all automatically persisted to the project folder.

You do need to be careful with the project folder approach, as if changes are made to the files in the project folder these get pulled back into the QVW. This is great for config control or bulk updates, but a real pain when it happens and you don't want it to.

If you search Community, or just Google, "project folders qlikview" you should find the info on these.

Steve