6 Replies Latest reply: Apr 15, 2014 4:30 PM by Kenneth Madsen RSS

    Global Static Variables

      I'm wondering the different ways this might be possible.


      Let's say I have a Project that performs certain logic on some sales data. This Project has 12 Dataflows. Each Dataflow has 4 steps, for a total of 48 Steps. Many of the Steps have a Filter that filters records based on a specific date & time. Many also have a Transform that assigns a static dollar amount to an attribute. Throughout the entire project, there could be dozens of these Filters and Transforms.


      The entire Project will get run every few days. But each time it is run, the date & time in the Filters need to be manually changed... as does the static dollar amount in the Transforms. While the values do need to be changed, they will all be the same value throughout the entire Project.


      So, my question is, in what ways might it be possible to set those variables in ONE place for the entire Project? I would really hate to have to go into each individual operator and change all of them manually.


      Thanks in advance!

        • Re: Global Static Variables

          There are two ways to do what you want.

          1. Set the filter constraints and dollar amounts as configuration values, which can be accessed from your code in the various operators.
          2. Set the filter constraints and dollar amounts as persistent values, which can be accessed from your code in the various operators.


          The better approach is option 2 as you will be able to change the constraints and amounts from a small script file or by issuing commands in an Expressor command window, rather than opening the project and making changes in a configuration artifact.


          Look in the documentation for discussion of persistent values and the utility.store... and utility.retrieve... functions that are used to store and retrieve persistent values.

            • Re: Global Static Variables

              "Look in the documentation for discussion of persistent values and the utility.store... and utility.retrieve... functions that are used to store and retrieve persistent values."


              Excellent! I didn't even think to go there. Thanks for the reference!

              • Re: Global Static Variables

                Thanks again!


                #2 worked like a champ. But #1 is a bit more finicky. To retrieve the value of the Parameter, I'm using:




                Unfortunately, this only seems to work for values that Expressor allows you to parameterize (see attached screenshot). I've added 'my_parameter' to the list of Parameters in the Configuration Artifact (and set a value).  But this:




                ...only returns 'nil'.


                If I change it to:




                ...which is the Host Parameter in my Connection, it returns the correct value: "MSSQL1". So I'm guessing if I parameterize an Artifact or Operator value with 'my_parameter', then it'll work. 'Course, that defeats the purpose.


                I'm not sure if it is something I'm doing, or if I'm just asking too much of Expressor. It'd be nice to have both options available for different scenarios. But I think Persistent Values could do by itself.



                  • Re: Global Static Variables

                    Yes, this is why I suggested #2 as the better approach.


                    That said, since your application was extracting other parameter values from the configuration artifact, my_Parameter should have been available to the expressor.NamedParameters.my_Parameter or expressor.NamedParameters['my_Parameter'] call.


                    This functionality within Expxressor is likely case sensitive, so be sure you refer to the value as my_Parameter (note the upper case P).

                      • Re: Global Static Variables

                        Hmmm... not sure what I'm doing wrong. I double-checked to make sure all the casings were consistent.  I also tried changing the calls to:   expressor.NamedParameters.my_Parameter


                        Still getting 'nil' on Parameters I manually added to the Configuration Artifact.




                        Oh well...


                        Not sure if it matters, I'm running version 3.9.1


                        Thanks for all your help!

                  • Re: Global Static Variables

                    We use the store/retrieve way of bringing in globals.  We have a file that just contains name/value pairs:


                    Name Value

                    OperatorTimeFactor 60

                    TempFolder "C:\expressortemp"


                    Then our first executed dataflow has a step that reads this file and sends it to a Write Custom operator with this in the function:


                    function write(input)


                       log.information("Global: "..input.Name..": "..input.Value)

                       return nil;



                    In dataflows that need a particular global, we would have this in some transform or other operator that is already in place:


                    function initialize()

                      factor = tointeger(utility.retrieve_string("OperatorTimeFactor"))

                      log.information("Factor: "..factor)



                    We also have places where we generate a global on the fly.  So we do some processing and we keep track of the maximum value of some attribute data.  In a finalize function in that transform, we use utility.store_integer (or whatever store function based on the datatype).  Then in later steps or dataflows, we have the corresponding retrieve_integer to use in that transform.