Assign Variable

This action is used to assign a value to a local, page, flow, or application variable. It can also be used to create a local variable.

When using code to reference a variable, the scope must be specified, unless it's defined in the current scope. If the scope isn't specified, it means it's the current scope. For example, on a page, the page's variables would be referenced as $variables.myVar instead of $page.variables.myvar.

Here's a sample code snippet that uses the Assign Variable action with the following logic: assign the value 12 to variable a, and 20 to variable b:
define([
  'vb/action/actionChain',
  'vb/action/actions',
  'vb/action/actionUtils',
], (
  ActionChain,
  Actions,
  ActionUtils
) => {
  'use strict';

  class test extends ActionChain {

    /**
     * @param {Object} context
     */
    async run(context) {
      const { $flow, $application, $constants, $variables } = context;

      const a = 12;
      const b = 20;
    }
  }

  return test;
});