SMARTBLOCKS:_COMMAND_REFERENCE_BY_CATEGORY

{{[[embed]]: ((3VJxxNhEu))}}

SmartBlocks Command Reference

Logic Control Commands

  • Variables

    • SmartBlocks can create and assign variables using the <%SET%> command, and retrieve the value of a variable with the <%GET%> command. Variables are case-sensitive.
    • 2: Value of variable
    • NotCe for JavaScript developers. All SmartBlocks variables are stored in a global associative array: roam42.smartBlocks.activeWorkflow.vars
    • GET
      • Purpose: retrieves a variable from memory
      • Parameters:
        • Variable name. Should contain only letters and number, no special symbols. Variables are case-sensitive.
      • Example:
        • <%GET:MyVariableName%>
    • SET
      • Purpose: Sets the value of a variable in memory. Variables are case-sensitive.
      • Parameters:
        • 1: Variable name
        • 2: Value of variable
      • Example:
        • <%SET:MyVariableName,my value%>
    • CLEARVARS
      • Purpose: Removes all variables from memory
      • Parameters: none
      • Example:
        • <%CLEARVARS%>
  • IF (use for basic text output)

    • Purpose: Performs simple IF/Then type logic commands. Intended for outputting text, not for processing other commands. Use IFTRUE if needed with other commands. Use in combination with <%THEN%> and <%ELSE%>
    • Parameters:
      • Logic to be evaluated. Uses Javascript like comparison logic.
        • == Equals Example: <%IF:2==(1+1)%>
        • != Not Equals Example: <%IF:2!=(1+1)%>
    • Example:
    • <%IF:2==(1+1)%><%THEN:The result is true%><%ELSE:The result is false%>
    • THEN and ELSE (use with IF)

      • Purpose: When and IF command evaluates to true, render the THEN commands. If it evaluates to FALSE render the ELSE commands.
        • Note: One block may have multiple THEN command
      • Parameters:
        • Text to be inserted into block
      • Example:
      • <%IF:2==(1+1)%><%THEN:The result is true%><%ELSE:The result is false%>
  • IFTRUE (use with commands)

    • Purpose: Tests the parameter if it is true. If it evaluates to true, the rest of the block is output. if false, the block is skipped (and all child blocks of the IFTRUE block)
    • Parameters:
      • Logic to be evaluated. Uses Javascript like comparison logic.
        • == Equals Example: <%IFTRUE:2==(1+1)%>
        • != Not Equals Example: <%IFTRUE:2!=(1+1)%>
    • Example:
      • <%IFTRUE:2==2%> this block will get output
      • <%IFTRUE:2==3%> this block will NOT get output
  • IFDAYOFMONTH

    • Purpose: Using todays date, compares to the day in the month to see if there is a match.
      • If they match, the block is inserted.
      • If there is no match, the block is not inserted
    • Parameters:
      • a number from 1 to 31 corresponding to the day in the month
      • Optionally a comma separated list of numbers to test for multiple days
    • Example:
      • <%IFDAYOFMONTH:1%> (Inserts this block if it is the first day of the month)
      • <%IFDAYOFMONTH:15,30%> (Inserts this block if it is the it is the 15th or 30th of the month)
    • Special notes:
      • IFDAYOFMONTH supports Date Basis “Time Machine mode”
  • IFDAYOFWEEK

    • Purpose: Using today's date, compares to the parameter to see if there is a match.
      • If they match, the block is inserted.
      • If there is no match, the block is not inserted
    • Parameters:
      • a number from 1 to 7, 1 is Monday, 2 is Tuesday and so on
      • Optionally a comma separated list of numbers to test for multiple days
    • Example:
      • <%IFDAYOFWEEK:1%> (This block will be inserted if today is Monday)
      • <%IFDAYOFWEEK:1,3,5%> (This block will be inserted if today is Monday, Wednesday or Friday)
    • Special notes:
      • IFDAYOFWEEK supports Date Basis “Time Machine mode”
  • INPUT

  • 42SETTING

    • Purpose: Roam42 supports the ability to define a setting that is used in the Roam42 engine. A setting is defined with the tag #42Setting followed by the setting name and then the setting value. This can be used by a SmartBlock Builder to store permanent values to be used in a script.
    • Parameters:
      • 1: Name of the setting to retrieve
    • Example:
      • With the following defined in your graph:
        • #42Setting MySetting MyValue
      • Workflow could use:
        • <%42SETTING:MySetting%>
        • will return MyValue

Date/Time Commands

  • DATE

    • Purpose: Using Roam42's date natural language processor, to return a properly formatted Roam date is resolved from the provided parameter. An optional second parameter allows you to control the format of the date returned
    • Parameters:
      • 1: An expression that will resolve to a date.
      • 2: Optional parameter that tells Roam42 to not return a Roam formatted date, but a date formatted in the format you specify. Roam42 supports the date formats defined here: https://day.js.org/docs/en/parse/string-format
        • Examples:
          • YYYY-MM-DD
            • 2020-10-12
          • MMM DD Oct 12
          • ww returns week number
    • Examples:
      • <%DATE:Today%>
      • <%DATE:Friday%>
      • <%DATE:Friday%>
      • <%DATE:5 days from now%>
      • <%DATE:In two weeks%>
      • <%DATE:In two weeks,YYYY-MM-DD%>
    • Special notes:
      • DATE supports Date Basis mode.
      • DATE also supports special abbreviations:
        • DBOM or DEOM = Beginning/End of month
        • DBONM or DEONM = Beginning/End of next month
        • DBOY or DEOY = Beginning/End of year
        • DBONY or DEONY = Beginning/End of next year
  • TIME

    • Purpose: Inserts the time in 24 hour format
    • Parameters: no parameters
    • Example:
      • <%TIME%>
  • TIMEAMPM

    • Purpose: Inserts the time in AM/PM format
    • Parameters: no parameters
    • Example:
      • <%TIMEAMPM%>
  • DATEBASIS

    • Purpose: Changes the date basis used by Roam42 in determining the context in which dates are calculated. By default, TODAY's date is the basis for all commands.
      • Video explanation of DATEBASIS:
      • This command sets the mode for the workflow. You can change between modes in one workflow.
      • DATEBASIS should not be used in conjunction with other commands in one block, except for: GET, IFTRUE, 42SETTING, RESOLVEBLOCKREF.
    • Parameters:
      • 1: Date basis to be used in the workflow
        • If DNP - will use the date of the Daily Notes Page if the workflow is rune on a DNP
        • Otherwise provide a NLP date command to determine the date basis
    • Examples:
      • <%DATEBASIS:DNP%>
        • Use the Daily Note Page date that the workflow is run on, if its not a DNP it will use Today's date
      • <%DATEBASIS:today%>
        • Use today's date as the basis
      • <%DATEBASIS:in 3 days%>
        • Use the date 3 days from now as the date basis
      • <%DATEBASIS:in two weeks%>
  • “Time Machine mode” Understanding the way dates are handled in Roam42 for advanced workflows

    • All date commands use today's date as a reference point in time for how they determine the date to be used in the command. However some commands support the concept of a "mode" that tells Roam42 how to behave when a date command is used on a Daily Notes Page (DNP). A Daily Notes Page is a dated page. If you work on a future Daily Notes Page (DNP), you may want your workflow to use the date from the DNP and not Today's date as the reference point. You can use the DATEBASIS command to create a time machine to move you forward or backward in time.

Serendipity - unleash your randomness

  • RANDOMBLOCK

    • Purpose: Serendipity generator. Grabs a random block from your graph and inserts it
    • Parameters: no paremeters
    • Example:
      • <%RANDOMBLOCK%>
  • RANDOMBLOCKFROM

    • Purpose: returns a random block from a page or a child block from a parent block provided in the parameter
    • Parameters: One paremeter with two options:
      • Option 1: Page name or tag name (Do not include brackets [[]] or hashtag # unless they are a part of the page name)
      • Option 2: Parent block UID
    • Example:
      • <%RANDOMBLOCKFROM:Evergreen Notes%>
      • <%RANDOMBLOCKFROM:QtEh1mKbD%>
  • RANDOMBLOCKMENTION

    • Purpose: returns a random block from places where the page is referenced
    • Parameters: One parameter with following possibilities
      • Page name or tag name (Do not include brackets [[]] or hashtag # unless they are a part of the page name)
    • Example:
      • <%RANDOMBLOCKMENTION:Evergreen Notes%>
  • RANDOMPAGE

    • Purpose: Serendipity generator. Grabs a random page from your graph and inserts it
    • Parameters: no parameters
    • Example:
      • <%RANDOMPAGE%>

Workflow Commands

  • BREADCRUMBS

    • Purpose: Returns the path of parents for a given block reference
    • Parameters:
      • 1: Block Reference UID
        • Add a + to front of UID to get back just the parent block
        • Add a - to get back just the path, without the parent block
      • 2: Separator to be used to separate each parent
    • Example:
      • `<%BREADCRUMBS:(( UID )),>%>
        • Will use > as a separator between block refs
      • `<%BREADCRUMBS:+(( UID )),>%>
        • Returns just the parent block
      • `<%BREADCRUMBS:-(( UID )),>%>
        • Returns just the path blocks, no parent
  • CLIPBOARDCOPY

    • Purpose: Writes text content to the clipboard
      • May not work in all browsers, please test in your environment
    • Parameters: text to be written to the clipboard
    • Example:
      • <%CLIPBOARDCOPY:This text is written to clipboard%>
  • CLIPBOARDPASTETEXT

    • Purpose: Reads the text of the clipboard as text
      • May not work in all browsers, please test in your environment
    • Parameters: no parameters
    • Example:
      • <%CLIPBOARDPASTETEXT%>
  • CURRENTBLOCKREF

    • Purpose: returns the block ID for the current block
      • May not work in all browsers, please test in your environment
    • Parameters: no parameters
    • Example:
      • <%CURRENTBLOCKREF%>
  • CONCAT

    • Purpose: Combines a comma separated list of strings into one string
    • Parameters Comma separated list
    • Examples:
      • <%CONCAT:[,[pageName],]%>
        • outputs [[pageName]]
      • <%CONCAT:[,[pageName],]]\, followed by more text%>
        • outputs [[pageName]]], followed by more text
        • Special note: if you want a comma to be a part of the output, put a \ in front of it as in this last example
  • CURRENTPAGENAME

    • Purpose: Returns the name of the current page. This command contributed by David Vargas of roamjs.com
    • Parameters: no parameters
    • Example:
      • <%CURRENTPAGENAME%>
  • CURRENTBLOCKREF

    • Purpose: stores the current block reference in a variable that can be used later by GET or JavaScript
    • Parameters: Name of variable
    • Example
      • <%CURRENTBLOCKREF:varName%>
        • Will store the current block reference into a variable named varName
  • CURSOR

    • Purpose: define where cursor should be located after the workflow completes.
      • if a workflow contains multiple <%CURSOR%> commands, the last instance of it will be used. If there were multiple <%CURSOR%> commands left over after workflow is run, only the last instance is replaced.
    • Parameters: no parameters
    • Example:
      • <%CURSOR%>
  • NOCURSOR

    • Purpose: After a SmartBlock has finished running, Roam should be left in a non-edit state, meaning no block currently has editing focus
    • Usage
      • NOCURSOR is a directive that runs at the SmartBlock level. So do not use it in a block as a normal command, but rather in the parent block where the SmartBlock is defined you add this command. Example:
        • #42SmartBlock NameOfSmartBlock <%NOCURSOR%>
      • Warning If you use the experimental <%SMARTBLOCK%> command, only one SmartBlock in the call chain should use <%NOCURSOR%>. Otherwise, it is likely the call chain will break, even causing unexpected results.
  • EXIT

    • Purpose: Stops the workflow from going further after completing the current block.
    • Parameters: no parameters
    • Example:
      • <%EXIT%>
  • FOCUSONBLOCK

    • Purpose: Will focus on this block after the workflow finish's running
      • if a workflow contains multiple <%FOCUSONBLOCK%> commands, the last instance of it will be used. It is good to use this command in conjunction with <%CURSOR%> to control the final cursor destination in the workflow
    • Parameters: no parameters
    • Example:
      • <%FOCUSONBLOCK%>
  • INDENT/UNINDENT

    • Purpose: Indent or un-indent the current block if possible.
      • Note: Indentation and un-indentation may not work in every context. So test carefully
    • Parameters: None
  • NOBLOCKOUTPUT

    • Purpose: Will prevent the block from being output from the workflow, no matter what other commands it contains. This is useful to do operations in the workflow that have no visual rendering (reading clipboard, setting variables)
    • Parameters: no parameters
    • Example:
      • <%NOBLOCKOUTPUT%>
  • NOTIFICATION

    • Purpose: Displays a small popup notification message in the lower right.
    • Parameters:
      • 1: Number of seconds the notification is visible.
      • 2: Message to be displayed. Supports basic HTML elements in the message.
    • Example:
      • <%NOTIFICATION:10,Welcome to my SmartBlocks%>
        • Displays the notification for 10 seconds with the text "Welcome to my SmartBlocks"
      • <%NOTIFICATION:120,Welcome to my SmartBlocks%>
        • Displays the notification for 2 minutes (120 seconds) with the text "Welcome to my SmartBlocks"
  • RESOLVEBLOCKREF

    • Purpose: Converts a block reference (()) into its text equivalent
    • Parameters: Block Reference
    • Example 1:
      • <%RESOLVEBLOCKREF:H9gC0rSaM%>
        • or
      • <%RESOLVEBLOCKREF:((H9gC0rSaM))%>
  • RESOLVEBLOCKREFATEND

    • Purpose: Does the same things as RESOLVEBLOCKREF, however runs toward the end of the Workflow after most other commands have been run. The parameters and usage are the same as defined for RESOLVEBLOCKREF
  • REPEAT

    • Purpose: Repeats the current block a specified amount of times.
      • Video Demonstration of Repeat
      • <%GET%> works with Repeat as a parameter, but no other commands can be used as a parameter
      • NOTE: Do not use with multi-block commands
      • WARNING: This can be recursive and lock up your graph if you are not careful. Second, it doesn't have a limit so you can insert 1000's of blocks (probably not a great idea)
    • Parameters: Count of repeats.
    • Example 1:
      • <%REPEAT:5%>

Workspace commands

  • These commands help you control the Roam environment (loading a page, loading side bars, toggling sidebars).
    • Note: since these commands change the state of your Roam environment, you need to test the workflow thoroughly.
  • OPENPAGE

    • Purpose: Opens a page or block
    • Parameters: Page name or block UID
    • Example:
      • <%OPENPAGE:My Page%>
        • Opens the page in the main window
      • <%OPENPAGE:AHJf_Kq_Q%><%GOTOBLOCK:1%>
        • Opens the block ref and will then go to first block for editing
  • SIDEBARWINDOWOPEN

    • Purpose: Opens a page or block into the sidebar
      • Supports GOTOBLOCK subcommand
      • Add <%GRAPH%> for it to open in graph mode
      • PENDING: <%REFERENCETO%> for it to open in "Reference to" mode in sideba
    • Parameters:
      • Accepts a page name or block reference
    • Example:
      • <%SIDEBARWINDOWOPEN:My Page%>
        • Opens the page in the side bar
      • <%SIDEBARWINDOWOPEN:AHJf_Kq_Q%>
        • Opens the block ref in a side bar
      • <%SIDEBARWINDOWOPEN:AHJf_Kq_Q%><%GRAPH%>
        • Opens te block ref in a side bar in graph mode
  • SIDEBARWINDOWCLOSE

    • Purpose: Closes a window in the right sidebar or all windows
    • Parameters:
      • Accepts one parameter
      • 0 will close all windows in the right sidebar
      • a number from 1 on will close the corresponding sidebar based on its position. Window 1 is at top and numbers down
    • Example:
      • <%SIDEBARWINDOWCLOSE:0%>
        • Closes all sidebar windows
      • <%SIDEBARWINDOWCLOSE:1%>
        • Closes just the first window in the sidebar
  • SIDEBARSTATE

    • Purpose: changes the state of either the left or right sidebar
    • Parameters:
      • Accepts one parameter, a value of 1 to 4
      • 1 opens the left sidebar
      • 2 closes the left sidebar
      • 3 opens the right sidebar
      • 4 closes the right sidebar
    • Example:
      • <%SIDEBARSTATE:2%>
        • Closes the left sidebar
      • <%SIDEBARSTATE:3%>
        • Opens the right sidebar
  • Subcommands for Workspace

    • GOTOBLOCK
      • Purpose: selects either the first or last block for editing
      • Parameters:
        • Accepts one parameter, either 1 or -1
        • 1 moves focus to first block
        • -1 moves focus to last block

Multi-block Commands (TODO & QUERY)

  • Multi-block commands return multiple blocks with just one command. They are not designed to work with other commands. Additionally, multi-block commands support special subcommands that provide additional detail.
    • Supported subcommands

      • Optionally subcommands can be included to return additional information with multi-block commands
      • <%PAGE%>
        • Inserts the page reference for the output block.
          • Video of using <%PAGE%> subcommand:(No Audio)
      • <%PATH:%>
        • Returns the path of blocks leading to the output block with defined separator
          • Video showing <%PAGE%> and <%PATH:%> together:
        • <%PATH:%> supports one parameter, which is the separator between blocks in the path.
          • <%PATH:>%>
            • Uses > as a separator between block
      • Example of us
  • TODO - Roam to Done (RTD not GTD)

    • TODO commands are multi-block commands and are not intended to be used with other commands except for IF commands
    • TODOTODAY

      • Purpose: Returns a list of block references of TODOs for today
        • Includes support for the <%PAGE%> Subcommand
      • Parameters:
          1. Maximum amount of block references to return.
          1. optional filter parameter based on a comma separated list (case-insensitive). Can use - in front of a word to exclude it.
          • Examples:
            • toRead,Pinnacle
              • returns blocks with toRead AND Pinnacle in the text
            • toRead|Pinaccle
              • returns blocks with toRead OR Pinnacle in the text
            • toRead,-Pinnacle
              • returns blocks with toRead but not if they have pinnacle
      • Example: <%TODOTODAY:20%>
    • TODOOVERDUE

      • Purpose: Returns a list of block references of TODOs for overdue TODOs. That is TODOs that have a dated page reference in them.
        • Includes support for the <%PAGE%> Subcommand
      • {{[[embed]]: ((((xn2foNtEM))))}}
      • Examples: <%TODOOVERDUE:20%>
    • TODOOVERDUEDNP

      • Purpose: Returns a list of block references of TODOs for overdue TODOs. That is TODOs that have a dated page reference in them. Additionally TODOs that are on a Daily Notes Page (DNP) without a date from the past. The idea is if you put a TODO on a DNP and its not finished, its likely overdue when that date has passed.
        • If a block on a DNP contains a date, the date in the block takes precedence over the date of the DNP. So if the date is for the future, even though recorded in the past, it will not be considered overdue.
        • Includes support for the <%PAGE%> Subcommand
      • {{[[embed]]: ((((xn2foNtEM))))}}
      • Examples: <%TODOOVERDUEDNP:20%>
    • TODOFUTURE

      • Purpose: Returns a list of block references of TODOs for future TODOs. That is TODOs that have a dated page reference in them.
        • Includes support for the <%PAGE%> <%PATH%>
      • {{[[embed]]: ((((xn2foNtEM))))}}
      • Examples: <%TODOFUTURE:20%>
    • TODOFUTUREDNP

      • Purpose: Returns a list of block references of TODOs for future TODOs. That is TODOs that have a dated page reference in them. Additionally TODOs that are on a Daily Notes Page (DNP) without a date on a future date. The idea is if you put a TODO on a DNP in the future, its likely also considered a future task.
        • Includes support for the <%PAGE%> <%PATH%> Subcommand
      • {{[[embed]]: ((((xn2foNtEM))))}}
      • Examples: <%TODOFUTUREDNP:20%>
    • TODOUNDATED

      • Purpose: Returns a list of block references of TODOs with no date
      • {{[[embed]]: ((((xn2foNtEM))))}}
      • Examples: <%TODOUNDATED:20%>
  • Query Commands

    • Query commands are not designed to be used with other commands as they repeat across multiple blocks.
    • BLOCKMENTIONS

      • Purpose: returns a list of blocks that mention a page reference, with optional filtering. This is a multi-block commands and has some limitations how it interacts with other commands.
        • Video of how to use: (No Audio)
      • Parameters: List of comma separated parameters
        • 1: Maximum amount of block references to return.
          • if set to -1, will return only count of matches
        • 2: Page name or tag name (This parameter is case-sensitive and must match your page or tag name as used in your graph)
        • 3 to X: Optional filtering parameters, with support for include and excluding blocks based on their text with simple text comparison
      • Example:
        • <%BLOCKMENTIONS:15,toRead%>
          • Returns up to 15 blocks that mention #toRead or [[toRead]]
        • <%BLOCKMENTIONS:15,toRead,book%>
          • Returns up to 15 blocks that mention #toRead or [[toRead]] that also have book in the text of the block
        • <%BLOCKMENTIONS:15,toRead,book,pinnacle%>
          • Returns up to 15 blocks that mention #toRead or [[toRead]] that also have book and pinnacle in the text of the block
        • <%BLOCKMENTIONS:15,toRead,book,-pinnacle%>
          • Returns up to 15 blocks that mention #toRead or [[toRead]] that also have book but not pinnacle in the text of the block
    • BLOCKMENTIONSDATED

      • Purpose: returns a list of blocks that mention a page reference, based on a specified date range, with optional filtering. This is a multi-block commands and has some limitations how it interacts with other commands.
        • Video of how to use: (No Audio)
      • Parameters: List of comma separated parameters
        • 1: Maximum amount of block references to return.
          • if set to -1, will return only count of matches
        • 2: Page name or tag name (This parameter is case-sensitive and must match your page or tag name as used in your graph)
        • 3: Start date - tasks with a date from start date and beyond until parameter 3 (End Date). Date NLP is supported, so you can do something like: Today, yesterday, 2020-12-31 and other formats.
          • Set to 0 for no start date
          • Set parameter 3 and 4 to -1 to have it return blocks that have no date in them
        • 4: End Date - all tasks from the end date and before, until parameter 2 (start date). Date NLP is supported, so you can do something like: Today, yesterday, 2020-12-31 and other formats.
          • Set to 0 for no end date
        • 5 to X: Sort Order
          • ASC - oldest dated blocks to newest
          • DESC - newest dated blocks to oldest
          • NONE - no sort defined, just return them the way the Roam database engine return them
        • 6: Optional filtering parameters, with support for include and excluding blocks based on their text with simple text comparison. Filters are processed before date processing. This means if filters are designed to include or exclude text, they will be processed before the dates are processed.
      • Example:
        • <%BLOCKMENTIONSDATED:10,TODO,2020-12-1,2020-12-30,ASC%>
          • Returns all blocks with [[TODO]] with a date reference from date Dec 1 to Dec 30, 2020 and do so in ascending order
        • <%BLOCKMENTIONSDATED:10,toRead,0,yesterday,DESC,-book%>
          • Returns all blocks with [[toRead]] with a date reference up to end of December but don't have book in the text and the list the blocks in date descending order
    • SEARCH

      • Purpose: searches all blocks for a specific string of case-sensitive text and returns a list of matching block references, with optional filtering. This is a multi-block commands and has some limitations how it interacts with other commands.
        • Video of how to use: (No Audio)
      • Parameters: List of comma separated parameters
        • Parameter 1: Maximum amount of block references to return.
        • Parameter 2: string of text to find (CASE-SENSITIVE) - this is a current limitation of Roam API. We hope this can be changed in future
        • Parameter 3 to X: Optional filtering parameters, with support for include and excluding blocks based on their text with simple text comparison. NOT... NOT case-sensitive. The filtering parameters can be mixed case.
      • Example:
        • <%SEARCH:15,apple pie%>
          • Returns up to 15 blocks that contain "apple pie"
        • <%SEARCH:15,apple pie,ice cream%>
          • Returns up to 15 blocks that contain "apple pie" and "ice cream"
        • <%SEARCH:15,apple pie,ice cream. chocolate%>
          • Returns up to 15 blocks that contain "apple pie" and "ice cream" and "chocolate"
        • <%SEARCH:15,apple pie,ice cream. chocolate,-vanilla%>
          • Returns up to 15 blocks that contain "apple pie" and "ice cream" and "chocolate", but not including "vanilla

JavaScript for super powers

  • JAVASCRIPT or J

    - **Purpose**: Executes Javascript code, and the results are inserted into the block
        - **Warning:** Javascript gives a lot of freedom, but can also lead to unpredicatable results. Test your code thoroughly and be careful if you copy in code from other sources, as this can be a security issue if you are not caerful.
        - Shorthand for JAVASCRIPT command is J
    - **Parameters**: a string of javascript code. Note this can be combined with the RESOLVEBLOCKREF to use a block to store javascript code. 
    - **Example**:
        - **<%JAVASCRIPT:** return "5+5 = " + (5+5) **%>**
            - or
        - Example with Block Reference:
            - Reference block (not in a Roam code block)
                - var dt = new Date();
    
    return dt.getMonth()
    - Command:  `#42SmartBlock `
                - <%JAVASCRIPT: return 5+5%>
                    - or shorthand version:
                        - <%J: return 5+5%>
    
  • JAVASCRIPTASYNC or JA

    • Purpose: Executes Javascript code using ASYNC, and the results are inserted into the block. Async is good for web services and functions that deal with call backs
      • Warning: Javascript gives a lot of freedom, but can also lead to unpredicatable results. Test your code thoroughly and be careful if you copy in code from other sources, as this can be a security issue if you are not caerful.
      • Shorthand for JAVASCRIPT command is JA
    • Parameters: a string of javascript code. Note this can be combined with the RESOLVEBLOCKREF to use a block to store javascript code.
  • ONBLOCKEXIT

    • Purpose: This is a helper function for JavaScript developers to work with the DOM or to perform post processing. It is called after a block has completely processed by the Roam42, just before the next block from the workflow is processed. ONBLOCKEXIT accepts async Javascript.
      • The code that is called will be handled asynchronously, similar to JAVASCRIPTASYNC
      • No return values are processed by the SmartBlocks Engine
    • Parameters: a string of JavaScript code.
    • Example:
      • Example PENDING