Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Persistent Variables now available in Power Scripts™ for Jira and Confluence

Starting with version 4.1.7 of the SIL Engine we are happy to introduce the Persistent Variables feature. We are really excited to introduce this new feature which is available in both Power Scripts for Jira and Power Scripts for Confluence as we know how sought after it is in the Atlassian Community. 

Persistent Variables for Jira

A Persistent variable is a value inherently linked to  a specific issue or it can be a global value. It is like an extension of the issue fields, or an additional custom field, but internal to SIL™. 

Outside the issue context, the persistent variable becomes a global variable which opens up a world of possibilities as global variables can be shared and are accessible from all scripts. Even if instances need to be restarted, persistent variables will remain in the system and will not need to be rewritten.

Usage in an Issue Context

Persistent variables are introduced via the persistent keyword. You cannot have persistent and constant modifiers used on the same variable. A persistent variable is always modifiable.

  1. The persistent variable is linked to the current issue from the context.
  2. Persistent variables are only initialized once. Initialization of a persistent variable will be ignored if that variable was already initialized from a previous execution within a particular context.
  3. A persistent variable is a variable whose value survives the script, making it available in many other scripts under the same name.

Usage Outside the Issue Context

The usage outside the issue context is the same. However, due to the nature of the persistent keyword, the variable becomes a global variable.

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:

  • getPersistentVar (Simple Issue Language™) — Gets the persistent var, as a string
  • setPersistentVar(Simple Issue Language™) — Sets the persistent var, as a string

Need some inspiration for how to use Persistent Variables in Jira? Why not try the following suggestions:

 

  • Create an approval process (approval stored as a persistent variable which can't be changed through UI.)
  • Track time in progress by setting start/stop times as persistent variables then use a scripted field to display the time interval between them.
  • Store passwords needed by some script files to sign in easily.

 

Persistent Variables for Confluence

Persistent Variables are even MORE exciting in Confluence as currently, Confluence does not even have custom fields with which to fabricate the effects of Persistent Variables today.

The Persistent Variable in Confluence can be created:

  • in the scope of the Page.
  • in the Global scope.

How it works

Creating a Persistent Variable in the Scope of the Page

With the help of certain script you can add a persistent variable counter to any page to act as a page view counter. 

Notes:

  • When you create a copy of the page it will not keep the page view counter.
  • If you restart your Confluence instance the page will not keep the page view counter. 
  • Only admins can see the page count. They can use this to then order content into "most viewed pages" for readers.

Example - Scope of the Page

  1. To start with, let's look into page counter. With the help of below script you can initialize, return and then increment it.

page counter.png

2. To use the script, you have to add a SIL™ Script macro, that executes a SIL™ script with persistent page counter.

persistent variables SIL macro.png

3. That's it, it returns 0 on your Page.

persistent variables test.png4. If you refresh the page the counter will be incremented because the script is executed again and persistent variable is updated. So, as long as the script is executed again, and again, this persistent variable is updated. It is the one which actually executes in the context of the page.

persistent variables increment result.png

This use case can easily be inserted so Confluence page admins can see which pages are popular and which are not. They can then use this information to showcase "trending/ most popular pages" or archive pages which are not relevant anymore. 

As the saying goes, "persistence is key!" so now you can go forth and reach previously uncharted Jira and Confluence heights thanks to our new Persistent Variables! 

 

 

0 comments

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events