Syntax and types introduction
This page provides an overview of the basic elements of the Simple Issue Language (SIL™) scripting syntax.
SIL is a scripting language specifically designed for Jira. It follows common programming language conventions but is tailored to work with Jira issues and workflows. SIL is the underlying scripting language of Power Scripts, Power Actions, and other apps. It is easy to learn and work with.
Basic syntax rules
Every instruction must end with a semicolon
;
Comments can be written in two ways:
// For single line comments /* For multi-line comments */
Data types
Data types are templates or definitions that tell the system what kind of data can be stored. SIL uses several categories of data types.
Basic data types
Type | Use for |
---|---|
| text values like |
| true/false values |
| any numeric value |
| whole numbers without decimals |
| for byte values |
| for dates like |
| for time periods like |
Complex data types
Arrays
Arrays are created by adding []
after any basic type. The following list represents valid arrays:
string[]
one-dimensional array of stringsboolean[
one-dimensional array of booleansnumber[][]
two-dimensional array of numbersinteger[]
one-dimensional array of integersdate[][][]
three-dimensional array of datesinterval[]
one-dimensional array of intervals
You can also create arrays for a user-defined structure:
Person[][]
two-dimensional array of (Person) structures
Key-value arrays
Arrays in SIL act as maps where list positions serve as keys. Key-value arrays (or maps) are declared like regular arrays.
Learn more about using the indexing operator to create key-value maps and retrieve values from them.
Structures
Structures are user-defined data types. A structure in SIL is like a container that can hold different types of data together. The syntax for defining a structure is:
struct StructureName {
type1 field1;
type2 field2;
// ... more fields
}
The type of each field can be a basic data type, a user-defined structure, a self-referential structure, or arrays of these types. The following examples show how to define a structure with each type:
struct Address {
string street;
string city;
string zipCode; //Basic data types in structure
}
struct Employee {
string id;
string name;
Address workAddress; // Structure inside structure
Address homeAddress; // Can use same type multiple times
}
struct Department {
string name;
Department parent; // A Department can reference itself
Department[] subDepartments; // Can have array of same type
}
Best practices when creating structures:
Use meaningful field names.
Group related fields together.
Consider the logical hierarchy of your data.
Once you've defined a structure, you can create variables of that structure type and work with them in two ways:
You can create a structure variable and set each field individually. Here is an example of field-by-field initialization:
Alternatively, you can do a one-line initialization, including nested initialization. Here’s an example of one-line initialization:
To access the value of a field from a variable in a structure, use the following syntax:
Literals
Literals are fixed values that appear directly in the code. In SIL, literals are used to represent constant values of different data types.
Literals refer to the constant values used in scripts, NOT the use of a constant which is the read-only attribute of variables.
Type | Example |
---|---|
Basic type literals | |
String, date, and interval literals | These types require double quotes (" "). |
Array literals | Arrays use curly braces and commas: |
Special literals | You can use |
Variables
Variables are named containers that use the data types. They are like labeled boxes that can hold specific values.
You can create an array from variables as illustrated in the following example:
You can also create array variables:
Variable declaration and initialization
To give a value to your variables, you initialize them either when you declare them or later.
Constants
Variables can be made read-only by adding the keyword const
before the data type when the variable is first defined.
Explicit type casting
When types are compatible, SIL automatically converts one type to another. Automatic conversion can lead to ambiguous results. If you want to tell SIL how to convert a type, use explicit type casting with the following syntax:
The following example illustrates how explicit type casting returns accurate results:
User-defined functions
SIL comes with many built-in functions. In addition, you can define local functions, referred to as user-defined functions (UFRs). To define and declare a function, use this general syntax:
For additional details, see the User-defined functions (UDFs) topic.