3 Replies Latest reply: Feb 2, 2013 2:23 PM by John Lifter RSS

    Environment Variable for directory in File Connection?

      I would like to have my %QVDPATH% variable stand in place of the "directory location" for my output directory.  I've seen how to do this for the Qlikview product, by examining the Registry - but how do I accomplish this in Expressor?

        • Re: Environment Variable for directory in File Connection?

          Which version of Expressor are you using?  Desktop or Standard or Enterprise?


          Look in the documentation for information on the Write Parameters operator.


          I'll give this a bit of thought first before responding.

          • Re: Environment Variable for directory in File Connection?

            There are actually several ways to do this with QlikView Expressor, but the approach is dependent on which version of Expressor you are using.


            With the Desktop version, the free installation of Expressor Studio, you can only use the first approach that utilizes the Write Parameters operator.  With this approach, you use the first step of a dataflow to read the value of QVDPATH from the system environment and write it to an in memory parameters listing, associating it with the name of the operator property you want to alter.


            With Expressor, each operator is uniquely identified through a combination of the name of the step on which the operator is placed, the name of the operator, and the name of the property you want to change.  For example, assume that on Step_2 of a dataflow you have a Write File operator named File Output and you want to change the file system location to which it writes files.  The operator property that designates the location is named connection.FileConnection.Path, so the unique name with which you want to associate the path value is "Step_2@File Output@connection.FileConnection.Path".  It's a good idea to always include this name within quotation marks, which allows spaces in your operator names.


            To retrieve an environment variable you use the os.getenv function, supplying the name of the environment variable.  In this example, the function call os.getenv("QVDPATH") will return the desired file system location.


            So, how do you retrieve this value so that it can be written by the Write Parameters operator?  You use the Read Custom operator.  On Step_1 of your dataflow, place and connect the Read Custom and Write Parameters operators.  To the Read Custom operator, add two string attributes - name and value - then use code similar to the following to retrieve the value of the environment variable and create a record that will be passed to the Write Parameters operator.  Note how the code retrieves and writes a single parameter.  You can easily modify the code to retrieve and write as many parameters as you wish by controlling the number of times the Expressor runtime invokes the read function.


            On the second step of the dataflow, include whatever operators are needed to perform the processing logic.  The Write File operator named File Output will write its output file to the location specified in the QVDPATH environment variable.


            With the Standard or Enterprise versions of QlikView Expressor you may use the two alternative approaches that use either a Configuration artifact or a substitution file.  With these approaches, it is necessary to run the dataflow within a command window, which is a feature available with these licensed versions of Expressor.  There is a knowledge base article that details these alternative approaches.