getPersistentVar

Availability

This routine is available starting with Power Scripts™ for Confluence v1.1.0.

Syntax

getPersistentVar(pageId, varName)  // get page persistent variable

getPersistentVar(varName)          // get global persistent variable

Description

Gets the specified persistent variable as a string.

Parameters

Parameter name

Type

Required

Description

pageId

numberNoID of the page to get persistent variable for
varNamestringYesPersistent variable name

Return type

string

Returns the value of the specified persistent variable.

Examples

Example 1

This example gets the value of the page persistent variable named "pageViews".

const string varName = "pageViews";
const number pageId = getPage("TEST", "Example page");
const number pageViews = getPersistentVar(pageId, varName);  // conversion from string to number is performed automatically


Example 2

This example gets the value of the global persistent variable named "globalCounter".

const string varName = "globalCounter";
const number globalCounter = getPersistentVar(varName);  // conversion from string to number is performed automatically


See also