Variables

Variables are dynamic key/value pairs that can be used to configure your application at runtime. By using Variables, rather than static texts, you can master the following scenarios easily:

  • Workflow-Application customizations (branding, multi-tenancy)

  • Different runtime settings (staging vs. production)

  • Company data (name, address, contacts)

  • Simple Rule Values (e.g., credit account)

To see and configure Variables at runtime, use the Engine Cockpit Variables View on the Axon Ivy Engine.

Variables Editor

Use the Variables Editor to create, delete, and edit Variables.

Variables Editor

Variables Editor

Variables Tree View

Shows the Variables of the current project.

  • Click the plus icon to add a new child Variable to the currently selected Variable. If no Variable is selected, a Variable is added at the topmost level.

  • Click the trash icon to delete the currently selected Variable.

  • Use the search bar to filter the Variables. If part of a Variable’s name or value matches the search text, all of its parents and children are shown.

Variables Detail View

Shows the details of the selected Variable.

  • Name The name is the identifier of the Variable (e.g. user).

  • Value The value is the default value of the Variable (e.g. username for the user Variable).

  • Description You can add a description to explain the purpose of the Variable.

  • Metadata If applicable, you can specify additional metadata for a Variable:

    • Password: This tells the Axon Ivy Engine to encrypt the value of this Variable.

      Tip

      If you add a password Variable in the Axon Ivy Designer, you get a validation warning that the Variable is not encrypted. You can fix this via a Problems View > QuickFix.

    • Daytime: The value of this Variable is interpreted as a time of day.

    • Enum: You can use this option to define a list of possible values that this Variable is allowed to take on.

    • File: This option configures the value of this Variable to be read from an external file. This file can be a .json or a .txt file. If your Variable is called myFile and it should be a JSON file, then your file must be located at <project>/config/variables/myFile.json. Alternatively, the variables prefix can also be part of the filename rather than a parent directory. So, the file <project>/config/variables.myFile.json can contain the value for the Variable called myFile.

Tip

If your Variable has password or secret in its name (e.g., hidePasswordMenu) and no metadata option is chosen, the Axon Ivy Engine will automatically treat this Variable as a password for increased security.

Warning

The Variables Editor interprets and formats the content of variables.yaml. If you make manual changes to variables.yaml, pay attention to the following points to prevent the loss of data:

  • Make sure the content is valid YAML.

  • Make sure variables.yaml contains exactly one top-level key with the name Variables.

  • Only put comments at the start or end of the file or before a Variable.

How to Access Variables

To access the Variables in your code, you can use the var method. In IvyScript, you can use the name of the Variable to get access to your defined Variables. In addition, this approach has the advantage that you receive validation notifications when a Variable is removed by a developer.

ivy.var.myVariable;

If you want to access Variable Metadata, you can also use the var keyword. This delivers an interface. From the interface, you can get a Variable object. This object contains additional metadata for that Variable.

ivy.var.variable("myVariable").description();