/
How to work with issue data in different contexts

How to work with issue data in different contexts

The issue context provides a streamlined approach where fields are directly accessible, while dynamic context allows you to work with multiple issues simultaneously. Understanding these contexts is key to writing effective scripts.

This straightforward approach to issue contexts makes it easy to master SIL scripting with just a few examples. Once you understand when to use each context and the associated syntax, you'll be able to write powerful automation scripts for your Jira instance.

Working with dynamic context

Dynamic context in SIL scripts allows you to access and modify field values across multiple issues. This approach uses specific syntax to indicate which issue's fields you're reading from or writing to, enabling bulk operations and cross-issue automation.

Reading field values from other issues

Example 1: Reading values with dot notation

string[] issueKeys = selectIssues("project = Test"); for(string key in issueKeys) { runnerLog(key + " - " + key.summary); }

Uses simple dot notation (key.fieldname) to read field values from other issues. This approach provides a straightforward way to access field values when you only need to read data.

The dot notation syntax (issueKey.fieldName) can only be used for reading values and cannot be used to modify fields.

Setting field values in other issues

Example 1: Writing values with substitution syntax

string[] issueKeys = selectIssues("project = Test"); for(string key in issueKeys) { %key%.labels = "newLabel"; }

Uses the substitution syntax with percent signs (%issueKey%) to create an editable reference to another issue. This format converts the issue key string into an editable issue object.

When updating field values in other issues, you must use the substitution syntax with percent signs (%issueKey%). Without this syntax, the issue reference is read-only and cannot be modified.


Working with issue context

Scripts running in an issue context have direct access to all fields of that specific issue. This simplifies field access as you don't need to specify which issue you're working with - the current issue is automatically available.

Reading field values in issue context

Example 1: Reading values from current issue

runnerLog(assignee); runnerLog(attachments); runnerLog(description);

Directly accesses field values from the current issue without needing to specify an issue key or context. All standard and custom fields are immediately available by their names or aliases.

For a full list of standard variables that are already ready for use when running in the context of an issue, see
Variable types and reference methods.

Setting field values in issue context

Example 1: Writing values to current issue

description += "\nThis extra bit of text was added using SIL!";

Directly modifies field values in the current issue without needing special syntax. You can read, write, or update any available field using simple variable references.

This script assumes that it is running in the context of an issue, like in a workflow script or listener. When testing outside this native context in the SIL Manager, you must add an issue key in the Run Configuration settings to provide the necessary context.

 

 

Related content