Variable resolution

This page explains how Simple Issue Language (SIL ™) identifies and accesses different types of variables in scripts. It covers standard Jira fields, custom fields, and user-defined variables while providing detailed guidance on various referencing methods and pre-declared variables.

Basic concepts

Variable resolution is how SIL identifies and accesses different types of variables in your scripts - whether they're standard Jira fields, custom fields, or your own variables. Understanding variable resolution is crucial for writing effective SIL scripts, as it determines how you can reference and manipulate issue data.

  • Variables in SIL can be standard Jira fields, custom fields, or user-defined variables.

  • Resolution refers to how SIL finds and accesses these variables.

  • Context determines how you can reference variables:

    • Implicit reference (in issue context) is used when your script runs in the context of a specific issue.

    • Explicit reference (any context) is used when you need to reference specific issues or related issues.

To learn more about context, see the Issue context page.


Issue reference in SIL

Pre-declared variables are automatically available in SIL scripts, letting you access information about issues using either direct field names or through specialized issue reference syntax patterns.

Standard (pre-declared) variables

SIL automatically pre-declares all standard issue variables and their synonyms. For example:

  • key represents the issue key

  • id represents the issue ID

  • summary represents the issue summary

Don’t redeclare these pre-declared variables; this will cause errors in your code.

Specialized issue reference syntax patterns

SIL provides three ways to reference and access issue data through specialized syntax patterns.

Reference

Syntax pattern

Description

Reference

Syntax pattern

Description

Parent issue reference

parent.fieldName

  • Refers to the parent ID

  • Only valid for subtasks

Example

parent.id // Parent issue's ID parent.summary // Parent issue's summary parent.status // Parent issue's status // Example usage if (parent.status == "Done") { summary = "Parent is completed: " + parent.summary; }

Direct issue reference

issueKey.fieldName

  • Refers to the specific issue in the project

  • The issue must exist and you must have appropriate permissions

Example

PROJ-123.id // Specific issue's ID PROJ-123.summary // Specific issue's summary PROJ-123.assignee // Specific issue's assignee // Example usage PROJ-123.assignee = currentUser(); PROJ-123.labels += "needs-review";

Substitution

%issueKey%.fieldName

  • Used for dynamic issue access when issue keys are stored in variables

  • Best suited for accessing issues in loops (for, while, do-while) or when creating an issue from the SIL Manager

Example

string k = "PROJ-123"; %k%.reporter = currentUser(); // Sets reporter on PROJ-123 %k%.summary = "Updated Summary"; // Sets summary on PROJ-123

Here’s how it works:

  • Variable k contains an issue key, such as string k = "PROJ-123";

  • The substitution %k% uses the value of the variable to access a specific issue

  • The .fieldName accesses that that specific issue's field (like reporter or summary)


Field reference in SIL

SIL provides flexible ways to access both standard and custom Jira fields through different reference methods.

Variable substitution

Variable substitution is a mechanism in SIL that lets you dynamically access fields using variables. Instead of directly referencing a field name, you can store the field name in a variable and use that variable to access the field. It uses the basic syntax %variableName%.

When SIL encounters %variableName%, it performs two steps:

  • Step 1: SIL reads the value stored in the variable.

  • Step 2: SIL uses the retrieved value as the field name to access.

Examples

This basic example illustrates the variable substitution mechanism:

These examples illustrate the two common use cases for variable substitution:

  • Custom field access

  • Dynamic field updates

This example shows how to validate variables and check if a field exists:

Custom fields

In addition to standard issue fields, SIL provides three ways to access custom fields:

  • By field ID

  • By field name

  • By field alias (if configured)

Examples

This example shows three ways of accessing a custom field:


Standard variables reference

These standard variables represent core issue data like summary, description, and status. They are already pre-declared in SIL. When your script runs in an issue context, you can use these variables directly without specifying an issue. However, outside of issue context, you must explicitly reference the issue context.

Variable

Aliases

SIL type

Read-only

Explanation

Variable

Aliases

SIL type

Read-only

Explanation

affectedVersions

affectedVersion
affectedVers
affectedVer
affVers
affVer

string []

The affected versions field of the issue

assignee

none

string

Username of the assignee of the issue

attachments

attach

string []

The filenames of the attachments

components

component
comps
comp

string []

The components of the issue

created

none

date

Timestamp of the date when the issue was created

description

desc

string

The description of the issue

dueDate

due

date

The due date of the issue

estimate

est
remaining

interval

Remaining estimate

environment

env

string

The environment of the issue

fixVersions

fixVersion
fixVers
fixVer

string []

Target fix versions of the issue

id

none

integer

Internal issue ID

issueCreator

none

string

Username of the creator

issueType

type

string

The name of the issue type

issueTypeId

none

string

The ID of the issue type

key

none

string

The issue key

labels

none

string []

The labels of the issue

originalEstimate

origEstimate
origEst

interval

The original estimate of the issue

parent

none

string

The parent issue key

parentId

none

integer

The ID of the parent issue

priority

prio

string

The name of the issue priority level

priorityId

none

string

The ID of the issue priority level

project

prj

string

The project key

projectId

none

integer

The internal ID of the project

reporter

none

string

Username of the reporter

resolution

res

resol

string

The name of the resolution state

resolutionId

resId

resolId

string

The ID of the resolution state

resolutionDate

none

date

The current resolution date

securityLevel

security

string

The name of the security level

securityLevelId

securityId

integer

The ID of the security level

status

none

string

The name of the current status

statusId

none

string

The ID of the current status

summary

none

string

The summary of the issue

timeSpent

spent

interval

Total logged time on the issue

updated

none

date

Last update timestamp

It will update automatically after the current transition.

votes

none

integer

The number of votes this issue has

watchers

none

string []

The usernames of the watchers of the issue

workflow

wrkflw
wf

string

The workflow scheme name applied to the issue

workflowId

none

integer

The workflow Scheme ID applied to the issue