Skip to end of banner
Go to start of banner

setPersistentVar

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Availability

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

Syntax

setPersistentVar(pageId, varName, value)  // set page persistent variable

setPersistentVar(varName, value)          // set global persistent variable

Description

Sets the specified persistent variable as a string.

Parameters

Parameter name

Type

Required

Description

pageId

numberNoID of the page to set the persistent variable for
varNamestringYesPersistent variable name
valuestringYesPersistent variable value

Return type

boolean (true/false)
Returns true if persistent variable value was set successfully, returns false otherwise.

Examples

Example 1

This example assigns value 0 to a page persistent variable named "pageViews". If the variable doesn't exist it will be created.

const varName = "pageViews";
const number pageId = getPage("TEST", "Example Page");
setPersistentVar(pageId, varName, 0);    // a number will be converted to a string


Example 2

This example assigns value 100 to a global persistent variable named "globalCounter". If the variable doesn't exist it will be created.

const varName = "globalCounter";
const number value = 100;
setPersistentVar(varName, value);    // a number will be converted to a string


See also

  • No labels