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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

290 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you