Variable resolution

Looking for the documentation on the newest versions of SIL Engine and the Simple Issue Language for Jira 8 for Server/Data Center? Click here !

Contents

Referencing an Issue

By default, the issue standard variables are pre-declared along with their synonyms. For instance,the key is an issue standard variable. You should avoid to re-declare it, since it will lead to subtle errors. We recommend you to prefix your variables with certain string if you are unsure of its name.

There are certain constructs that reflect the issue structure, for instance:

  • parent.id - refers to the parent id, and it is valid only if this issue is a subtask
  • TSTP-123.id - refers to the issue TSTP-123 id (on the project TSTP)
  • %k%.id - (Substitution, see below) refers to the issue designed by k, where k is a string variable already defined, containing a valid issue key, like in this example:
string k = "TSTP-123";
%k%.reporter = currentUser();

Tip

You will see the last construct comes in hand when used in cycles (for, while, do-while) or when creating an issue from SIL.

Substitution

It often happens that you need the value of a variable designated by another value. For example, we might have a custom field that specifies what certain data other field contains. The general syntax for substituting variables is:

%varname%

The above expression will evaluate to the value designated by the variable name contained inside the value of varname.

Example
string myCustomField = "customfield_10000"; // myCustomField is a local variable
%myCustomField% = "a value";

 

Standard Variables

Here is a list of the variables that are already defined in a SIL environment and that you can use right away. Note that these are all standard issue fields.

Note

 Standard variables can be used without explicitly referencing the issue only when the script has an issue context.

Warning

Please do not redefine them. Redefinition is possible with the loss of the original meaning, so you will have subtle errors in your SIL code.

Variable

Aliases

Type

Readonly

Explanations and Usage

affectedVersions

affectedVersion
affectedVers
affectedVer
affVers
affVer

string []

no

The affected versions field of the issue. If attempting to add an invalid value, it will be ignored.

assignee

-

string

no

The assignee of the issue. Represents the user key, not the real name.

attachments

attach

string []

yes

The filenames of the attachments. There are routines to modify those

Availability

This field is available in Power Scripts for Jira server only. We plan to add it to the Cloud version too.

components

component
comps
comp

string []

no

The components of the issue. If attempting to add an invalid value, it will be ignored.

created

-

date

yes

The date when the issue was created.

description

desc

string

no

The description of the issue.

dueDate

due

date

no

The due date of the issue.

Availability

This field is available in Power Scripts for Jira server only. We plan to add it to the Cloud version too.

estimate

est
remaining

interval

no

This is displayed as "Remaining" in the Jira interface. Requires TimeTracking.

environment

env

string

no

The environment of the issue.

fixVersions

fixVersion
fixVers
fixVer

string []

no

The fix versions field of the issue. If attempting to add an invalid value, it will be ignored.

id

-

number

yes

The id of the issue.

issueCreator-stringyesRepresents the user key of the creator.

issueType

type

string

no

The name of the issue type.

issueTypeId

-

string

no

The id of the issue type.

key

-

string

yes

The key of the issue.

labels

-

string []

no

The labels of the issue.

originalEstimate

origEstimate
origEst

interval

no

The original estimate of the issue. Requires TimeTracking.

parent

-

string

no (yes, since 1.4.3)

The key of the parent issue.

parentId

-

number

no (yes, since 1.4.3)

The id of the parent issue.

priority

prio

string

no

The name of the priority.

priorityId

-

string

no

The id of the priority.

project

prj

string

no

The key of the project.

projectId

-

number

no

The id of the project.

reporter

-

string

no

Represents the user key, not the real name of the reporter.

resolution

res

resol

string

no

The name of the resolution. When set will also modify the resolution date.

resolutionDate

-

date

yes

The current resolution date. If the resolution is modified, the date will also be updated.

resolutionId

resId

resolId

string

no

The id of the resolution. When set will also modify the resolution date.

securityLevel

security

string

no

The name of the security level.

securityLevelId

securityId

number

no

The id of the security level.

status

-

string

yes

The name of the status.

statusId

-

string

yes

The id of the status.

summary

-

string

no

The summary of the issue.

timeSpent

spent

interval

no

The time spent (logged work) on the issue. Requires TimeTracking.

updated

-

date

yes

The date when this issue was last updated. It will update automatically after the current transition.

votes

-

number

no

The number of votes this issue has.

watchers

-

string []

no

The watchers of the issue. The elements in the array are usernames.

Availability

This field is available in Power Scripts for Jira server only. We plan to add it to the Cloud version too.

workflow

wrkflw
wf

string

no (yes, since 1.4.3)

The workflow name of the issue.

Availability

This field is available in Power Scripts for Jira server only. We plan to add it to the Cloud version too.

workflowId

-

number

no (yes, since 1.4.3)

The workflow id of the issue.

Custom Fields

Aside from the standard issue fields, you can also access custom fields from SIL selecting from the one of the following three ways:

  • by id, using the construct customfield_xxxxx - where xxxxx is the ID of the custom field.
  • by name - don't forget to use #{ and } if the name contains spaces.
  • by its alias.

 

Examples
customfield_10000 = "http://bugs.kepler-rominfo.com/browse/TST-1"; // referencing by id
External = "http://bugs.kepler-rominfo.com/browse/TST-1"; // referencing by name
#{External URL} = "http://bugs.kepler-rominfo.com/browse/TST-1"; // referencing by name with spaces

Note

If you have multiple custom fields with the same name, the Jira API returns the first one it finds.

See also