This page documents all 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 | ||||||
---|---|---|---|---|---|---|
|
Packages
All The following packages are provided by Canvas, and which can be used in block JS-Javascript code:
Table of Contents | ||||||||
---|---|---|---|---|---|---|---|---|
|
api
api package contains methods for working with CMA API.
...
Table of Contents | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
api.get
Sends get request to endpoint by specified url. Is asynchron method.
...
Expand | ||
---|---|---|
| ||
|
api.getDirect
Sends get request to endpoint on specified CMA API server by specified url. Is asynchron method.
...
Expand | ||
---|---|---|
| ||
|
api.post
Sends post request to endpoint by specified url. Is asynchron method.
...
Expand | ||
---|---|---|
| ||
|
api.postDirect
Sends post request to endpoint on specified CMA API server by specified url. Is asynchron method.
...
Expand | ||
---|---|---|
| ||
|
fx
fx is a package, which contains functions provided by CMA, but also can be increased by organizations specific functions. Some functions are grouped by packages including applications specific functions.
Full documentation of all functions you can get by this link.
logger
logger is a package which helps to work with User Logs in block JS-code.
The package contains just one log method.
Expand | ||
---|---|---|
| ||
|
Code Block |
---|
return arr; |
Note |
---|
Please note that following values will be converted to null and logged as null then:
|
myVault
This page documents 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 | ||
Writes key and value into myVault dictionary on the workflow complete event | ||
Reads value from myVault dictionary by specified key | ||
Removes key-value pair from myVault dictionary by specified key | ||
Determines whether the myVault dictionary contains the specified key |
myVault.set
Writes key and value into myVault dictionary belonged to the workflow.
...
Expand | ||
---|---|---|
| ||
|
myVault.setGlobal
Writes key and value into Global myVault dictionary belonged to the account.
...
Expand | ||
---|---|---|
| ||
|
myVault.setOnComplete
Writes key and value into myVault dictionary belonged to the workflow.
This method differs from myVault.set method in “saving into myVault is deferred” condition and will be executed on workflow complete event.
Parameters
key
-the key of the element to set.
...
Please also see session.vault by this link
Please see conditionas for “Workflow complete“ by this link
myVault.setGlobalOnComplete
Writes key and value into Global myVault dictionary belonged to the account.
This method differs from myVault.setGlobal method in “saving into Global myVault is deferred” condition and will be executed on workflow complete event.
Parameters
key
-the key of the element to set.
...
Please also see session.vaultGlobal by this link
Please see conditionas for “Workflow complete“ by this link
myVault.get
Reads value from myVault dictionary by specified key.
...
Expand | ||
---|---|---|
| ||
|
myVault.getGlobal
Reads value from Global myVault dictionary by specified key.
...
Expand | ||
---|---|---|
| ||
|
myVault.remove
Removes key-value pair from myVault dictionary by specified key.
...
Expand | ||
---|---|---|
| ||
|
myVault.removeGlobal
Removes key-value pair from Global myVault dictionary by specified key.
...
Expand | ||
---|---|---|
| ||
|
myVault.contains
Determines whether the myVault dictionary contains the specified key
...
Expand | ||
---|---|---|
| ||
|
myVault.containsGlobal
Determines whether Global myVault dictionary contains the specified key
...
Expand | ||
---|---|---|
| ||
|
Properties
All properties provided by Canvas and which can be used in block JS-code:
Table of Contents | ||||||
---|---|---|---|---|---|---|
|
Datasource
Datasource is an array of block responses, which dependency is set for the block
Expand | ||||
---|---|---|---|---|
| ||||
|
Expand | |||||
---|---|---|---|---|---|
| |||||
|
\uD83D\uDCCB Related articles
...
Please see also Response by this link
dateLastRun
dateLastRun is a global workflow property which can be used in js-code. The property value is a date and time when a workflow was processed successfully last time. If workflow is a new and has not been run before, then property value is NULL.
dateLastRun
dateLastRun is a global workflow property which can be used You can see the value of workflow dateLastRun on the Workflow list page or read this value in js-code. The property value is a date and time when a workflow was processed successfully last time. If workflow is a new and has not been run before, then property value is NULL.
You can see the value of workflow dateLastRun on the Workflow list page or read this value in js-code.
Rules when dateLastRun is updated
There is a list of cases when dataLastRun is updated:
when processed block was stopped programmaly with fx.stopAfterThisBlock(true).
\uD83D\uDCCB Related articles
You can know how to start workflow running by this link
You can know how to stop workflow running by this link
session
This page documents session object which is shared between all blocks in the workflow and contains following properties:
Table of Contents |
---|
Rules when dateLastRun is updated
There is a list of cases when dataLastRun is updated:
when processed block was stopped programmaly with fx.stopAfterThisBlock(true).
\uD83D\uDCCB Related articles
You can know how to start workflow running by this link
You can know how to stop workflow running by this link
session
session is an object which is shared between all blocks in the workflow and contains following properties:
Table of Contents | ||||||
---|---|---|---|---|---|---|
|
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 | ||||
---|---|---|---|---|
| ||||
|
Expand | |||
---|---|---|---|
| |||
|
Note |
---|
Please note that overriding of session.vault is forbidden. For example, you will not be able to set following:
|
session.vaultGlobal
session.vaultGlobal is an object of keys-value pairs which was set by myVault.setGlobalOnComplete() method and which will be moved into Global myVault on workflow complete event.
Expand | ||||
---|---|---|---|---|
| ||||
|
Expand | |||
---|---|---|---|
| |||
|
Note |
---|
Please note that overriding of session.vaultGlobal is forbidden. For example, you will not be able to set following:
|
session.vars
session.vars is an object which Canvas provides for keeping of global variables in workflow context, which are not included into block responses.
Expand | ||||
---|---|---|---|---|
| ||||
|
Note |
---|
Please note that overriding of session.vars is forbidden. For example, you will not be able to set following:
|
Methods
Canvas provides just 1 method which can be used in block JS-code, it is getVariables().
getVariables()
Returns array of block variables. No parameters.
Expand | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
let v = getWorkflowVariables(); let url = `quin/Sections?apikey=${v.apiKey}`; let sections = await api.get(url); |
...