Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt
hiddentrue

A persistent variable is a variable that continues to exist outside of the scripts execution.

What is a Persistent Variable?

A persistent variable is a variable that is used in a SIL script whose value continues to persist after the script is run. The values of these variables are stored and can be accessed by other scripts run in the future.

What are they used for?

Often, during the development of an integration or a special customization, people get stuck because of the lack of context. Questions appear: which user clicked the button for the next status? Did the manager approve this item? What was the result of the calculation in the previous step? The traditional way of dealing with such questions was to create additional custom fields to keep that data, usually hidden from users (so excluded from the screens schemes), effectively adding bloat to Jira and ultimately worsening indexing - and general - performance. To help you answer these kinds of questions, Simple Issue Language™ (or SIL™) acquired, starting with version 4.5.0 of the SIL Engine™, a new feature, called persistent variables.

A persistent variable is a value inherently linked to the issue. Think of it as an extension of the issue fields, or - making another analogy - an additional custom field, but internal to SIL™. Outside the issue context, the persistent variable becomes a global variable, accessible from all scripts. It is better to see some usage, so you can get a better grasp on what it means and how it can simplify your SIL™ usage throughout your Jira integration.

So, what's a persistent variable? In short, in an issue context, a persistent variable is a value inherently linked to the issue. Think of it as an extension of the issue fields, or - making another analogy - an additional custom field, but internal to SIL™. Outside the issue context, the persistent variable becomes a global variable, accessible from all scripts. It is better to see some usage, so you can get a better grasp on what it means and how it can simplify your SIL™ usage throughout your Jira integration.

Helper Routines

There are two helper routines available to ease your work with persistent variables. These routines allow you to set or retrieve the value of a persistent variable from a script that is not in the context of the issue or just to retrieve a global variable:

Filter by label (Content by label)
showLabelsfalse
titleRoutines
excerptTypesimple
cqllabel = "persistent_vars"

Values are treated as strings. For the above example:

Code Block
languagejava
string globalCounterVar = getPersistentVar("counter");
number test_one_counter = getPersistentVar("TEST-1", "counter"); //notice the implicit cast! values are treated like strings, though!
  • Although useful, persistent variables come with a small performance penalty. Don't overuse them!

  • There's no way to delete a persistent var (other than direct SQL) at the moment. Think hard if you really need them

    Enter persistent variables, a way to store this information without introducing a new custom field to bloat the system.

    That's one scenario, however there are many more like storing usernames and passwords or storing file paths that are used across multiple scripts. There are many possibilities and basically persistent variables are there for you to store whatever you need.

    Issue context…what?

    So basically here are two types of persistent variables, those that are in an issue context and those that are not.

    • In an Issue Context - The value of these variables are tied to that issue specifically, just like a custom field would be.

    • Out of an Issue Context - The value of these variables is constant from issue to issue. These variables are global.

    See More

    Child pages (Children Display)