Table of contents


Roam42 maintains a set of global objects that are updated when a workflow is in process. A JavaScript developer can read these values and in some cases change them to affect the flow of a workflow. This section includes technical notes for JavaScript developers working with SmartBlocks


activeWorkflow contains information about the current workflow being run. When the next workflow begins, all values in this object are reset to null except for roam42.smartBlocks.activeWorkflow.vars.

As a convenience, there is a short version of this object called which can make code less verbose.


This is a shared variable storage for workflows. GET and SET read variables from this object, which is an associative array. Example:

<%SET:MyVar,MyValue%> can be retrieved with:


Or set in JavaScript with:

roam42.smartBlocks.activeWorkflow.vars["MyVar"] = "NewValue";

Note: the vars object does not persist, use localStorage from the browser if you need persistence


When the JAVASCRIPT and JAVASCRIPTASYNC commands are processed, this variable roam42.smartBlocks.activeWorkflow.blockContents holds the contents of the current block being process from the workflow. The JavaScritpt developer can read and write to this variable. Basically this is a way to intercept the current text in the block being processed without having to read or modify the DOM.

Contains the name of the currently (or last run) workflow


Contains the parent block reference UID of the workflow that currently (or last run)


The HTML element ID of the block from which the workflow was started


The text of the block from which the workflow was started


Contains text from the current block in the workflow before being processed (useful if you want to see the context of the entire block)


the HTML Element ID of current point of where the workflow is going to insert text at finish


If focus command was used, this contains the HTML Element ID of the block that will be focused upon completion


Call this command to output additional blocks after the current block finishes. This can be called multiple times to output multiple blocks


outputBlock - string of text to be inserted into the next block


There is an active community at channels #roam42 and #roam-js. Stop by if you need help or want to share your ideas.

End of SmartBlock information