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 |
---|---|---|---|
| number | No | ID of the page to set the persistent variable for |
varName | string | Yes | Persistent variable name |
value | string | Yes | Persistent 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