How to use Environment Variables in Channel Settings


You can use Iguana Environment Variables to set most string value Channel Settings, and also port numbers (for Iguana version 6.1.2 or higher). This can be particularly useful if you need to change settings between environments. For example: You could use a different Source Directory in a From File component, for development, testing and production. By using Environment Variables you can conveniently edit all your channel settings in one place — Settings > Environment Variables.

Note: You could also edit the channel settings directly, but this would be very laborious if you are running more than a few channels.

Task [top]

How to use Iguana Environment Variables to set Channel Property Settings.

Implementation [top]

This is a very simple process you simply create a new Iguana Environment Variable (or use an existing variable), and then access it in a Channel Setting field using the ${env_var_name} syntax.

Follow these steps:

  1. Create a new Iguana Environment Variable, or use an existing variable:

    You can create a new variable or use an existing variable — any Iguana Environment Variable can be used.

    • Create a new local environment variable: FILE_INPUT_DIRECTORY
  2. Optional: Set the value of the Environment Variable you are using:

    If you are creating a new variable you will need to initialize the value, however if you are using an existing variable you will probably not need to change it (though you can change it if required).

    • Set FILE_INPUT_DIRECTORY to: “/Users/<your user name>/Downloads/test/”
      Note: Use any file path so long as the directory exists and the Iguana Server user has read/write permission
      Environment variables
  3. Access the variable in the appropriate field in your Channel Settings:

    Be aware that this only works with most string value settings and port numbers (for Iguana version 6.12 or higher).

    • Use the Variable in a Channel component field, like this:
      Environment Variable in channel setting
  4. Your Channel settings should look something like this:
    Note: In this example we are using a From File component.
    environment variable for channel settings

How it works [top]

You can use an Environment Value to set most string value settings in a channel component, as well as port numbers (for Iguana version 6.1.2 or higher). This process works with any Iguana Environment Variable, however in most cases you will be using Local Iguana Environment Variables (that you create yourself). The variables are accessed in a Channel Setting field using the ${env_var_name} syntax.

There is one other thing that you need to be careful about — avoiding variable accidentally re-using the same variable in several channels.

For example if you have two channels that both use a From File component, say Foxton Hospital and Foxton Laboratory. And they use different source directories and process different file types.

  • Foxton Hospital:
    • Source Directory: C:\foxton\hospital
    • Extension of file to read: hl7, edi, txt
  • Foxton Laboratory:
    • Source Directory: C:\foxton\laboratory
    • Extension of file to read: csv, xls, txt

If both channels use the same Environment Variables (FILE_INPUT_DIRECTORY and FILE_EXTENSIONS) then we get a “name collision” — and the data will be incorrect for one or the other of the channels. To fix this we need to make sure the names are unique. The easiest way to do this is to add the channel name to the beginning of the Variable name. Using the channel names does get quite long but it guarantees uniqueness as channel names must be unique (within an Iguana Server instance).

The resulting variables with then be:

  • Foxton Hospital:
    • Source Directory: Foxton_Hospital.FILE_INPUT_DIRECTORY
    • Extension of file to read: Foxton_Hospital.FILE_EXTENSIONS
  • Foxton Laboratory:
    • Source Directory: Foxton_Laboratory.FILE_INPUT_DIRECTORY
    • Extension of file to read: Foxton_Laboratory.FILE_EXTENSIONS

By using the channel names the variables will be conveniently grouped by channel in Settings > Environment Variables which makes them easy to manage:

Note: Some of you will recognize that this is using namespaces to specify scope. But it not necessary to know this, the important thing is that using channel names makes the variable names unique.

More information [top]

Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.