Action Results

Actions in an action chain can return a result that can be used by subsequent actions in the chain.

After an action implementation is run, it may return a result.  The type of these results are specific to an implementation of an action. This result will be stored in a special variable, $chain.results. The results of a previous action are contained within $chain.results.<actionId>.

Example 1-47 Accessing a Previous Action`s Results

To access a previous action's results:

"myActionChain": {
  "root": "myAction",
  "actions": {
    "myAction": {
      "module": "vb/action/builtin/someAction",
      "outcomes": {
        "success": "someOtherAction"
      }
    },
    "someOtherAction": {
      "module": "vb/action/builtin/someAction",
      "parameters": {
        "myKey": "{{ $chain.results.myAction }}"
      }
    }
  }
}

Example 1-48 Action Chain Return Type and Outcomes

You can specify a return type and an array of outcomes. If a return type is specified, the result of the final outcome will be auto-mapped into the return type. If "outcomes" is specified, the name of the final outcome must match one of the possible outcomes. Otherwise, the action chain will fail. Here is an example:

"myActionChain": {
  "root": "myAction",
  "actions": {
    "myAction": {
      "module": "vb/action/builtin/someAction"
    }
  },
  "returnType": "application:someType",
  "outcomes": ["success", "failure"]
}

Action "failure" Outcomes

Actions return a standard object shape when returning a "failure" outcome. The result will be an object with the following properties:

  • "message": may contain one optional "summary" string property

  • "error": may contain an Error object

  • "payload": may contain any Action-specific additional information about the failure