Setting environment variables

Set environment variables to ensure that your business applications use the correct values in each environment where they are deployed.

About this task

Each application and toolkit that is created can include environment variables. You can set these environment variables to ensure that your applications are using correct values, whatever environment you deploy to, or whatever change occurs at run time in the environment. Suppose that your application includes an implementation that requires the status message to be displayed. By using an environment variable, you can set the status message for each environment in which the application runs. Plus, administrators can verify and adjust environment variable values from the Business Automation Navigator after the application is installed.
Note: Your administrator can verify and modify Application resources and Environment variables values from Business Automation Navigator.

Procedure

  1. Open your business application or toolkit.
  2. Click App Project Settings, then click Environment Variables.
  3. Click the Add environment variable button button to add a variable. To copy a variable from other applications or toolkits, click the Import environment variable button button. Importing is a quick way to add environment variables that are referred to by artifacts that are copied or moved from other applications or toolkits.
  4. Click the <NEW VARBL> placeholder in the Name cell, type the name of the new environment variable, and press Enter. Environment variable names must be valid JavaScript identifiers. They must begin with a letter or underscore and contain only letters, digits, or underscores.
    Tip: You can create objects with the use of multiple environment variables. If the environment variable names contain dots, the runtime attempts to create JavaScript objects based on the implied structure. So adding company.ID and company.name results in tw.env.company created as a JavaScript object with ID and name properties.
  5. Click the Value cell for the newly entered variable, and type in a value, which is always a string. Then, press Enter.
  6. To use one of several variables in a script in the current application, you can use the variable name that is preceded by tw.env. You can also use the variable name tw.env to access environment variables that are defined in the application and dependent toolkits. If the same name is defined in the application and a toolkit, the value that is defined in the application is used.
  7. If you want to remove an environment variable, click the cell of the variable, then click X.

What to do next

After you create your environment variable, you can use it in an Action. If you want to use your environment variable in an application, go to your application, then click the Variables tab, click Environment Variables, then add the environment variable that you created.