An attribute is part of a packet and defines a field for that packet.
Attributes can be displayed as single- or multiline text, checkbox, date or number.
There are several ways to populate lists:
To create list, the attribute type should always be “Text (One line)".
If a user should be able to specify an item that’s not in the list, then select option “New items allowed”.
Use field “List of values” in the attribute to specify the values separated by comma’s.
Each item can just a value, or a name-value pair.
Example: red,green,blue
The result of $instance.getAttribute("<attribute name>")
will be red
, green
, …
Example: GREEN=green,RED=red,BLUE=blue
The result of $instance.getAttribute("<attribute name>")
will be GREEN
, RED
, …
A dropdown can contain a list of the values of a specific attribute from other instances.
These instances can be selected in several ways.
To way instances are retrieved depends on the value of the “Source”-attribute:
An instance with Velocity name equal to attribute ‘Reference filter’ is selected as the root to search under. An error is displayed if no instance is found in the current environment with the specified Velocity name.
Only instances that exist on the current container can be added to the list.
Any instance in the environment can be added to the list.
See Dynamic lists in Infraxys-by-example.
A script can be used to generate the contents of a list.
The script is executed while opening instance forms and the form is only displayed after the list is populated.
Script results can be cached using field “Cache minutes”. The script (or Docker container) is only run again if the cache for the attribute has expired.
The cache for an attribute can be cleared through the “Clear list cache”-button in the attribute definition screen.
Attribute “Reference filter” should contain the filename of a script in the same packet.
The script is run in a Docker container.
You can change the default Docker image by providing one like
ubuntu:18.04
in the “Ref. value attribute”-field.
This allows you to specify images that have pre-populated lists in them or software that retrieves values from a database, object store, REST API, …
The structure of the output of the script is parsed in the following ways:
!!!values
(exact match), then all subsequent lines are treated as entries for the list.!!!name-values
(exact match), then all subsequent lines are treated as entries for the list. The name-part is stored in the attribute value and the value-part is displayed in the list.Examples:
echo "us-east-1,eu-west-1";
echo "us-east-1=United States,eu-west-1=Europe"
echo "US=us-east-1
BE=be-north-2"
#!/usr/bin/env sh
echo "Generating contents" # this is displayed nowhere when this script is run for dropdown population
cat << EOF
!!!values
us-east-1
eu-west-1
EOF
#!/usr/bin/env sh
echo "Generating contents" # this is displayed nowhere when this script is run for dropdown population
cat << EOF
!!!name-values
us-east-1=United States
eu-west-1=Europe
EOF
See Dynamic lists in Infraxys-by-example.
Infraxys lets you use a script or a custom Docker image to generate the contents of dropdowns.
Same structure applies as the output from scripts explained above, except that the Docker image, like ubuntu:18.04
is specified in the “Reference filter”.
Another difference is that the value of field “Ref. value attribute” is added to the command-line that’s used to run the Docker container.
This enables the use of one Docker image for several types of attributes.