---
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


---

# Subflow - Scoped (deprecated)

# Subflow - Scoped (deprecated) {#ariaid-title1}

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

The Subflow API provides methods to run published Workflow Studio subflows.

This API is deprecated and replaced by the [FlowAPI - Scoped, Global](https://servicenow-prod.fluidtopics.net/oW~16xYu7YXh0S2TGiCBRw#ScriptableFlowAPI "The FlowAPI provides methods to execute actions, flows, or subflows in server-side scripts using either blocking or non-blocking methods.").

The Subflow API can only be used in server scripts.

Use the `sn_fd` namespace to access the Subflow API.

Before interacting with a subflow using the Subflow API, you must first
create and publish the subflow in the Workflow Studio interface. Because the
Subflow API only interacts with pre-built subflows, there is no
constructor for the class.  
Note:  
To optimize instance performance, avoid calling these methods from an asynchronous business rule script. Instead, create a scheduled job record within the Workflow Studio UI.

## Subflow - startAsync(String scopeName.subflowName, Map inputs) {#ariaid-title2}

Runs a published subflow asynchronously.
Asynchronous calls are non-blocking, allowing the client to execute other code in the
script without having to wait for the subflow to complete.
{#SubflowScoped-startAsync_S_O__table_slq_v1v_ncb__entry__3}

| Name | Type | Description |
|-|-|-|
| scopeName.subflowName | String | The application scope for the subflow and the internal name of the subflow to run. If scopeName is not included, the scope of the user currently logged in is used. Retrieve the internal name of the subflow using the Internal name column on the Workflow Studio landing page. |
| inputs | Map | Name-value pairs that define subflow inputs. If a subflow includes mandatory inputs, they must be included. For inputs of Reference or Document ID field types, use a GlideRecord object as the value. |
[Table 1. Parameters]

{#SubflowScoped-startAsync_S_O__table_slq_v1v_ncb} {#SubflowScoped-startAsync_S_O__table_tlq_v1v_ncb__entry__2}

| Type | Description |
|-|-|
| Object | PlanResponse object containing the following properties: * contextId: Sys_id of the execution details record for the executed subflow. Access the execution details by navigating to the Flow Executions tab in Workflow Studio and filtering by sys_id. {#SubflowScoped-startAsync_S_O__ul_bd2_k2v_ncb} An exception occurs when the subflow: * Does not exist within the specified application scope, or the subflow or scope name has been misspelled. * Is not published. * Is passed an input object that does not match the subflow inputs. * Exceeds the recursion limit set by the com.glide.hub.flow_engine.indirect_recursion_limit system property. The default value is three. {#SubflowScoped-startAsync_S_O__ul_ub3_n3t_pcb} |
[Table 2. Returns]

{#SubflowScoped-startAsync_S_O__table_tlq_v1v_ncb}  

    //Run a subflow that takes two inputs: user, a sys_user record, and laptop_welcome_message, a string.
    (function startSubflowAsync() {

      try {
        var userToProvisionFor = new GlideRecord('sys_user');
        userToProvisionFor.get('62826bf03710200044e0bfc8bcbe5df1');

        var inputs = {};
        inputs['user'] = userToProvisionFor;
        inputs['laptop_welcome_message'] = 'Welcome Onboard!!';

        var result = sn_fd.Subflow.startAsync('sn_devstudio.provisionlaptop', inputs);

        //The Sys ID of a flow execution (contextId)
        var contextId = result.contextId;

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

    })();


