Project variables allow a user to save information in project-wide variables for use in custom transformations, scripts actions, custom views, customized code and selection rules. For example, this feature can be used to set up an environment specific selection rule that limits the amount of data loaded for testing purposes in a development environment, while all data is loaded in the production environment.
The value of a given variable is determined when you deploy the objects that use this variable. As such, when you have changed a variable it is important to deploy the objects that uses this variable. The exception is when you use project variables with customized code. Here, the value of the variables is determined on execution.
Dynamic project variables are project variables where the values are generated by a custom script written by the user.
Adding a Project Variable
To add a new project variable, follow the steps below.
1. In the project tree, right-click on the project name and click on Project Variable. The Project Variable window opens.
2. Click on Add. A new empty variable is added to the list.
3. In the Name column, type a name for the variable.
4. In the list in the Type column, click on the variable type you wish to use. the variable types are:
- Fixed: This is a fixed string supplied by the user
- System: This will use one of the following system properties:
- Machine Name: The Windows computer name
- Environment Name: The name of the current JDM environment if you are using Multiple Environments, such as “dev” or “prod”.
- User Name: Your Active Directory user name
- User Domain Name: The Active Directory domain you are connected to.
- Source Scope: A property of the source of the current object. For instance, if you use a source scope variable in a custom transformation rule on a table in the data warehouse, the variable will have the value of property on the relevant staging database. Examples of properties include Database Name, API Version, Host, File Name. Since different possible sources have different properties, the variable might not always have a value. For instance, a SQL data source does not have a file name.
- Destination Scope: A property of the destination of the current object, similar to source scope, but in the opposite direction.
- Contextual Scope: A property of one specific element in the project, such as database name on a particular staging database.
Adding a Dynamic Project Variable
To add a dynamic project variable to your project, follow the steps below.
- Right-click on your project in the project tree and click on Project Variable. The Project Variable window opens. Click on Add.
- Type a name for the variable in Name.
- In the Type list, select Dynamic.
- In the Resolve Type list, select when you wish to resolve the value of your dynamic variable. You have the following options:
- Every Time: Resolve the value every time the value is used.
- One Time: Resolve the value when the variable is used for the first time and reuse the resolved value for the following uses until the project is closed.
- Each Batch: Resolve the value once for each batch, e.g. an execution.
- In the Context list, select the context you want the variable to be resolved in.
- Click on Script Editor to open the standard script editor in JDM and use it to write the script that calculates the value of the variable.
- Click on OK.
Using a Project Variable in a Custom Transformation Rule, Script Action or Custom View
Project variables are available for use when writing a custom transformation rules, a script action or a custom view. The available variables are listed in the tree view in the right-hand side of the editor window. Simply drag the variable in from the tree to use it.
Note: The variable does not have a specific data type. If, for instance, you wish to use the variable as a string, make sure to enclose the variable in quotes in the script.
Using a Project Variable in a Selection Rule
To use project variables in conjunction with selection rules, follow the steps below. This can be used to define Environment Specific selection rules.
1. Right click on a selection rule in the project tree and click on Add Usage Condition. The Usage Condition panel is displayed in the right-hand side of the application window.
2. In the Usage Condition panel, click on the variable you wish to use.
- GreaterEqual (Greater than or Equal to)
- LessEqual (Less than or Equal to)
5. Type the value you wish to compare the parameter with in the Value box.
Using a Project Variable with Customized Code
Project variables are available as parameters when using the customized code feature. Click on Parameters next to a step you have customized on a particular table and select the project variables you wish to use in the Execution Parameters window that opens.