---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# ScriptableFlowRunnerResult - Scoped

# ScriptableFlowRunnerResult - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 5 minutes to read

Captures the result of using ScriptableFlowRunner to execute a flow, subflow, or action. Includes data such as the context ID, domain, and any outputs from the flow execution.
Use these methods in your server-side scripts with the `sn_fd` namespace
identifier.

## API call Order {#ScriptableFlowRunnerResultScopedAPI__section_idt_q3w_slb}

Build and execute flows, subflows, and actions using these APIs in the following order:  

1. FlowAPI: Creates a builder object
:   Use getRunner() to instantiate the ScriptableFlowRunner
    builder object.

2. ScriptableFlowRunner: Specify Workflow Studio content to run
:   Use these methods in the following order to create the builder pattern:  
    1. Use one of the methods action(), datastream(), flow(), or subflow() to specify what type of Workflow Studio object to build.
    2. Use one or more methods such as addInput(), inDomain(), or quick() to specify execution parameters.
    3. Use the run() method to run the action, flow, or subflow with the provided parameters and return a ScriptableFlowRunnerResult object.
    {#ScriptableFlowRunnerResultScopedAPI__ol_hcw_m4s_slb}

3. ScriptableFlowRunnerResult: Retrieve Workflow Studio execution details
:   Use one or more methods such as getContextId(),
    getOutputs(), and getDomainId() to
    view execution details.

## Example {#ScriptableFlowRunnerResultScopedAPI__section_afv_mjw_slb}

This example shows how to create a
ScriptableFlowRunner builder object and uses it to execute an approval action on a
specific record. A ScriptableFlowRunnerResult object captures the execution
arguments and action outputs.  


    (function() {
      try {

        var inputs = {}; 

        inputs['sys_id'] = '57af7aec73d423002728660c4cf6a71c';  // Pass the record's sys_id in as input.  

        var result = sn_fd.FlowAPI.getRunner()  // Create a ScriptableFlowRunner builder object.
          .action('global.markapproved')        // Run the global scope action named markapproved.
          .inForeground()
          .inDomain('TOP/ACME')                 // Run the action from the TOP/ACME domain.                               
          .withInputs(inputs)
          .run();                               // Run the action and return a FlowRunnerResult object.

        var contextId = result.getContextId();  // Retrieve the context ID from the result
        var dateRun = result.getDate();
        var domainUsed = result.getDomainId();  // Retrieve the Domain ID from the result.
        var flowName = result.getFlowObjectName();
        var flowObjectType = result.getFlowObjectType();

        var outputs = result.getOutputs();            // Retrieve any outputs from the action execution.
        var newApprovalStatus = outputs['approval'];  // Echo back the approval status for verification.
    		
      } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
      }
    	
    })();
       
## ScriptableFlowRunnerResult - debug() {#ariaid-title2}

Returns information about the executed flow, subflow, or action, including the context
ID, domain ID, and execution outputs.
{#FlowRunnerResult-debug__table_hys_1v5_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#FlowRunnerResult-debug__table_hys_1v5_rlb} {#FlowRunnerResult-debug__table_iys_1v5_rlb__entry__2}

| Type | Description |
|-|-|
| String | Execution details about the Workflow Studio action, flow, or subflow run. * flow object name: Name of the flow, subflow, or action. * flow object type: Flow, subflow, action, or datastream action. * domain ID: ID of the domain that the flow, subflow, or action ran in. * result time: Amount of time it took to run. * context ID: Sys_id of the Workflow Studio execution details record for the action, flow, or subflow. * output count: Number of action or subflow outputs. {#FlowRunnerResult-debug__ul_tcc_dqr_5lb} |
[Table 2. Returns]

{#FlowRunnerResult-debug__table_iys_1v5_rlb}  
This example shows how to retrieve information about the executed flow, subflow, or action
from the ScriptableFlowRunnerResult object.

    (function() {
      try {

        var result = sn_fd.FlowAPI.getRunner()
          .flow('global.test_flow')
          .inForeground()
          .timeout(12000)
          .run();

        gs.info(result.debug());

      } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
      }

    })();

Output:

    *** Script: FlowRunnerResult
    Flow Object Name: global.test_flow
    Flow Object Type: flow
    Domain: null
    Result Time: 2020-06-08 18:28:41
    ContextId: null
    Output count: 0

## ScriptableFlowRunnerResult - getContextId() {#ariaid-title3}

Returns the context ID of the flow, subflow, or action.
{#FlowRunnerResult-getContextId__table_dnx_p4p_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#FlowRunnerResult-getContextId__table_dnx_p4p_rlb} {#FlowRunnerResult-getContextId__table_enx_p4p_rlb__entry__2}

| Type | Description |
|-|-|
| String | The sys_id of the Workflow Studio execution details record for the action, flow, or subflow. |
[Table 4. Returns]

{#FlowRunnerResult-getContextId__table_enx_p4p_rlb}  
This example shows how to retrieve a context ID from a ScriptableFlowRunnerResult
object.

    var contextId = result.getContextId();

Output:

    4ecead85c4da1110598d0c7d6bf73554

## ScriptableFlowRunnerResult - getDate() {#ariaid-title4}

Returns the date and time when a Workflow Studio action, flow, or subflow
ran as a GlideDateTime object.
{#FlowRunnerResult-getDate__table_pwr_r4p_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 5. Parameters]

{#FlowRunnerResult-getDate__table_pwr_r4p_rlb} {#FlowRunnerResult-getDate__table_qwr_r4p_rlb__entry__2}

| Type | Description |
|-|-|
| GlideDateTime | The execution date and time for the flow, subflow, or action. |
[Table 6. Returns]

{#FlowRunnerResult-getDate__table_qwr_r4p_rlb}  
This example shows how to retrieve the date and time of a flow execution from a
ScriptableFlowRunnerResult object.

    (function() {
      try {

        var result = sn_fd.FlowAPI.getRunner()
          .flow('global.test_flow')
          .inForeground()
          .timeout(12000)
          .run();

        gs.info(result.getDate());

      } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
      }

    })();

Output:

    2020-05-22 18:45:42

## ScriptableFlowRunnerResult - getDataStream() {#ariaid-title5}

Returns the stream of data from a data stream action.
If the datastream() method was used in the
ScriptableFlowRunner builder class, this returns the stream of data as
a ScriptableDataStream object. Use the ScriptableDataStream class to
iterate over items in the stream. See [ScriptableDataStream](https://servicenow-prod.fluidtopics.net/~CG6KzOxPxol~TpeNSp2HA#ScriptableDataStreamAPI "The ScriptableDataStream API provides methods to interact with a stream of data.").

For more information about data stream actions, see [Data Stream actions and
pagination](https://www.servicenow.com/docs/access?context=data-stream-actions&version=xanadu&pubname=xanadu-integrate-applications&ft:locale=en-US).
{#FlowRunnerResult-getDataStream__table_vs4_w4p_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 7. Parameters]

{#FlowRunnerResult-getDataStream__table_vs4_w4p_rlb} {#FlowRunnerResult-getDataStream__table_ws4_w4p_rlb__entry__2}

| Type | Description |
|-|-|
| ScriptableDataStream | A ScriptableDataStream object you can use to iterate through items in a data stream. Use the methods in the ScriptableDataStream class to interact with this object. See [ScriptableDataStream](https://servicenow-prod.fluidtopics.net/~CG6KzOxPxol~TpeNSp2HA#ScriptableDataStreamAPI "The ScriptableDataStream API provides methods to interact with a stream of data."). |
[Table 8. Returns]

{#FlowRunnerResult-getDataStream__table_ws4_w4p_rlb}  
This example shows how to retrieve a data stream from a ScriptableFlowRunnerResult
object.

    var datastream = result.getDataStream();

## ScriptableFlowRunnerResult - getDomainId() {#ariaid-title6}

Returns the sys_id of the domain that the Workflow Studio action, flow, or
subflow ran in.
{#FlowRunnerResult-getDomainId__table_wzw_s4p_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 9. Parameters]

{#FlowRunnerResult-getDomainId__table_wzw_s4p_rlb} {#FlowRunnerResult-getDomainId__table_xzw_s4p_rlb__entry__2}

| Type | Description |
|-|-|
| String | The sys_id of the domain that the Workflow Studio action, flow, or subflow ran in. |
[Table 10. Returns]

{#FlowRunnerResult-getDomainId__table_xzw_s4p_rlb}  
This example shows how to retrieve a domain ID from a ScriptableFlowRunnerResult
object.

    (function() {
      try {

        var result = sn_fd.FlowAPI.getRunner()
          .flow('global.test_flow')
          .inForeground()
          .inDomain('TOP/ACME')
          .timeout(12000)
          .run();

        gs.info(result.getDomainId());

      } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
      }

    })();

Output:

    4ecead85a4da1110598d0c7d6bf75554

## ScriptableFlowRunnerResult - getFlowObjectType() {#ariaid-title7}

Returns the type of Workflow Studio object run.
{#FlowRunnerResult-getFlowObjectType__table_cmv_54p_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 11. Parameters]

{#FlowRunnerResult-getFlowObjectType__table_cmv_54p_rlb} {#FlowRunnerResult-getFlowObjectType__table_dmv_54p_rlb__entry__2}

| Type | Description |
|-|-|
| FlowObjectType | The type of Workflow Studio object run, which is either action, flow, or subflow. |
[Table 12. Returns]

{#FlowRunnerResult-getFlowObjectType__table_dmv_54p_rlb}  
This example shows how to retrieve the flow object type from the
ScriptableFlowRunnerResult API.

    (function() {
      try {

        var result = sn_fd.FlowAPI.getRunner()
          .flow('global.test_flow')
          .inForeground()
          .timeout(12000)
          .run();

        gs.info(result.getFlowObjectType());

      } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
      }

    })();

Output:

    flow

## ScriptableFlowRunnerResult - getFlowObjectName() {#ariaid-title8}

Returns the scope and internal name of the Workflow Studio action, flow,
or subflow run.
{#FlowRunnerResult-getFlowObjectName__table_ycz_t4p_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 13. Parameters]

{#FlowRunnerResult-getFlowObjectName__table_ycz_t4p_rlb} {#FlowRunnerResult-getFlowObjectName__table_zcz_t4p_rlb__entry__2}

| Type | Description |
|-|-|
| String | The scope and internal name of the Workflow Studio action, flow, or subflow run. For example, `global.emailflow`. |
[Table 14. Returns]

{#FlowRunnerResult-getFlowObjectName__table_zcz_t4p_rlb}  
This example shows how to retrieve the name of the flow, subflow, or action name from a
ScriptableFlowRunnerResult object.

    (function() {
      try {

        var result = sn_fd.FlowAPI.getRunner()
          .flow('global.test_flow')
          .inForeground()
          .timeout(12000)
          .run();

        gs.info(result.getFlowObjectName());

      } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
      }

    })();

Output:

    global.test_flow

## ScriptableFlowRunnerResult - getOutputs() {#ariaid-title9}

Returns the outputs of a completed Workflow Studio action, flow, or
subflow.
{#FlowRunnerResult-getOutputs__table_fxw_q4p_rlb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 15. Parameters]

{#FlowRunnerResult-getOutputs__table_fxw_q4p_rlb} {#FlowRunnerResult-getOutputs__table_gxw_q4p_rlb__entry__2}

| Type | Description |
|-|-|
| Object | Object containing the output of a completed Workflow Studio action, flow, or subflow. |
[Table 16. Returns]

{#FlowRunnerResult-getOutputs__table_gxw_q4p_rlb}  
This example shows how to retrieve the outputs from a Workflow Studio action,
flow, or subflow run with the ScriptableFlowRunner API.

    (function() {
      try {

        var result = sn_fd.FlowAPI.getRunner()
          .action('global.test_action')
          .inForeground()
          .timeout(12000)
          .run();

        gs.info(result.getOutputs());

      } catch (ex) {
        var message = ex.getMessage();
        gs.error(message);
      }

    })();

Output:

    Flow Designer: Warning. This is an important log message. 


