Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page documents following objects provided by Canvas and which can be used in block JS-code:Canvas has several useful helper functions built in which will help you speed up integration development.

There are functions for storing values between runs (myVault), checking when the workflow last ran (dateLastRun), logging data (logger), storing session variables (session), in addition to a large library of application specific functions (see the fx docs in Canvas).

This page provides an overview of these helper functions, which can all be used inside block code.

Table of Contents
minLevel1
maxLevel2

Packages

All The following packages are provided by Canvas, and which can be used in block JS-Javascript code:

Table of Contents
minLevel2
maxLevel2
includeapi|fx|logger|myVault

...

Expand
titleExample
Code Block
logger.log('Hello world!');');
Code Block
return arr;
Note

Please note that following values will be converted to null and logged as null then:

  • undefined

  • NaN

  • Infinity

  • '' - empty string

myVault

myVault is a package which contains methods for working with collections of keys-value pairs. All methods are grouped by access level type:

...

There are myVault methods which you can call in js-code:

Description

Workflow level

Account level

Writes key and value into myVault dictionary

set

setGlobal

Writes key and value into myVault dictionary on the workflow complete event

setOnComplete

setGlobalOnComplete

Reads value from myVault dictionary by specified key

get

getGlobal

Removes key-value pair from myVault dictionary by specified key

remove

removeGlobal

Determines whether the myVault dictionary contains the specified key

contains

containsGlobal

myVault.set

Writes key and value into myVault dictionary belonged to the workflow.

...

Table of Contents
minLevel3
maxLevel3includesession.*
includesession.*

session is stored for each workflow running. session is empty when new run is started (from first block) and is passed to next blocks till last. If you start running not from 1st block, for example from 3nd block, then session will be copied from 2nd block of previous running.

session.vault

session.vault is an object of keys-value pairs which was set by myVault.setOnComplete() method and which will be moved into myVault on workflow complete event.

...

Expand
titleExample

let v = getVariables();

let url = `quin/Sections?apikey=${v.apiKey}`;

let sections = await api.get(url);

getWorkflowVariables()

Returns array of workflow variables. No parameters.

Expand
titleExample

let v = getWorkflowVariables();

let url = `quin/Sections?apikey=${v.apiKey}`;

let sections = await api.get(url);

...