Create a sample flow that dynamically calls subflows for provisioning cloud services.

Before you begin

Role required: flow_designer or admin

About this task

To understand how to use the Dynamic Flow and Get Flow Outputs flow logic together, the flow that you create in this task dynamically runs subflows that are related to provisioning cloud services. This flow does the following:
  1. Triggers when a Cloud Instance Provisioning Request record is created.
  2. Calls the appropriate subflow to create a Cloud Instance record.
  3. Gets an output from the dynamically called subflow and updates the Cloud Instance Provisioning Request record with the output's value.

Procedure

  1. Navigate to All > System Applications > Studio.
  2. On the Select Application screen, click Create Application.
  3. On the Guided App Creator welcome screen, click Let's get started.
  4. In the Name field, enter Cloud Instance Provisioning and then click Create.
  5. In the Roles field, enter flow_designer or admin and then click Continue.
  6. From the list of app formats, select Classic and then click Continue.
  7. Select Create new table > Create table from scratch > Continue to create two new tables for your application.
    • Add the following fields for the first table and name the table Cloud Instance.
    • Add the following fields for the second table and name the table Cloud Instance Provisioning Request.
  8. After creating both tables, click Done with tables.
  9. Select Start > Create > Done with apps to finish creating your application.

Create a subflow template

Create a sample subflow template for provisioning cloud services.

Before you begin

Role required: flow_designer or admin

Procedure

  1. Under Business logic, process automation, and integrations, select Go to Flow Designer.
  2. In the Workflow Studio landing page main header, select New > New Subflow.
  3. On the Subflow Properties screen, enter TEMPLATE: Create Cloud Instance Record in the Name field and then select Submit.
  4. Under Inputs & Outputs, select the plus icon (Plus icon) to create two inputs for your subflow template.
    Label Type
    Requested by Reference.User
    Requested Instance Type String
  5. Select the plus icon (Plus icon) to create one output for your subflow template.
    Label Type
    Instance URL URL
  6. Under your output, select Done.
  7. Select the add action, flow logic, or subflow to end of flow icon (Add action, flow logic, or subflow to end of flow icon) and then select Action.
  8. From the list of ServiceNow Core actions, select Log.
  9. In the data panel, drag the data pills for the Requested by and Requested Instance Type inputs you created earlier, and drop both of the pills into the Message field.
  10. In the Subflow header, select Save and then select Publish to publish your subflow template.

Create a subflow for Jira cloud instance provisioning requests

Create a sample subflow for provisioning cloud services from Jira.

Before you begin

Role required: flow_designer or admin

Procedure

  1. In the Subflow header, select the more actions icon (More actions icon) and select Copy subflow.
  2. On the Copy Subflow screen, enter Create Cloud Instance Record - Jira in the New Subflow Name field, and then select Copy.
  3. Under the Log action, add a Create Record action.
  4. In the Table Name field, select Cloud Instance and then fill in the following fields.
  5. Under the create record action, select Add an Action, Flow Logic, or Subflow > Flow Logic > Assign Subflow Outputs.
  6. Select the plus icon to add an output.
  7. For Name, select Instance URL.
  8. For Data, select the data pill picker (Data pill picker) and then 2 - Create Record - > Cloud Instance Record > Instance URL
  9. In the Subflow header, select Save and then Publish to publish the subflow.

Create a subflow for Salesforce cloud instance provisioning requests

Create a sample subflow for provisioning cloud services from Salesforce.

Before you begin

Role required: flow_designer or admin

Procedure

  1. In the Subflow header, select the more actions icon (More actions icon) and select Copy subflow.
  2. On the Copy Subflow screen, enter Create Cloud Instance Record - Salesforce in the New Subflow Name field, and then select Copy.
  3. Expand the Create Cloud Instance Record action and replace the .atlassian.net value for the Instance URL field with .salesforce.com
  4. In the Subflow header, select Save, accept the data change warning message, and then Publish to publish the subflow.

Create a flow that runs your subflows dynamically

Create a sample flow to run your provisioning cloud services subflows.

Before you begin

Role required: flow_designer or admin

Procedure

  1. Under the Workflow Studio header, select the Create flow, subflow, or action(Create flow, subflow, or action icon) icon and select Flow.
  2. On the Flow Properties screen, enter Process Cloud Instance Provisioning Request in the Name field, and then select Submit.
  3. Under Trigger, select the plus icon Plus icon) to add a trigger to your flow, and then fill out the following fields.
    Field Value
    Trigger Select Created.
    Table Enter Cloud Instance Provisioning Request [x_cloud_instance_p_cloud_instance_provisioning_request].
  4. Under Actions, select the plus icon Plus iconand then select Flow Logic > Dynamic Flow.
  5. Fill in the following fields.
  6. Under your Dynamic Flow flow logic, add the Get Flow Outputs flow logic, and then fill in the following fields.
  7. For Flow Template, select TEMPLATE: Create Cloud Instance Record
  8. For Context, select the data pill picker (Data pill picker) and select 1 - Dynamic Flow - > Context.
  9. Under your Get Flow Outputs flow logic, select the plus icon (Plus icon) and then select Action > Update Record to add an Update Record action to your flow.
  10. Fill in the following fields.
    Field
    Record Select the data pill picker (Data pill picker) and select Trigger - Record Created > Cloud Instance Provisioning Request Record.
    Fields > Approved Instance Select the data pill picker (Data pill picker) and select 2 - Get Flow Outputs - > Instance URL.
    Fields > Approval Status Enter Approved.
  11. Select Save.

Test your flow

Test your sample flow for provisioning cloud services.

Before you begin

Role required: flow_designer or admin

Procedure

  1. In the Flow header, select Test to test your flow.
  2. On the Test Flow screen, select the Create new record (Create new record icon) icon to create a new record.
  3. For Requested By, select the Lookup using list icon (Lookup using list icon) and select any user from the list.
  4. For Requested Instance Type, enter either Jira or Salesforce.
    The value you enter determines which subflow runs dynamically at runtime. Entering Jira runs the Create Cloud Instance Record - Jira subflow, and entering Salesforce runs the Create Cloud Instance Record - Salesforce.
  5. Select Submit.
  6. Select Run Test, and when the flow finishes running, select Your test has finished running. View the flow execution details.
    Your flow runs successfully if the values in the State column for each step in your flow shows Completed and each step's runtime value populates appropriately.
  7. Select the tab for your Process Cloud Provisioning Requests flow and close the Test Flow modal.
  8. In the Flow header, select Activate to make your flow accessible within the Cloud Instance Provisioning Application scope.

Result

When a user in your instance creates a new record in the Cloud Provisioning Request table, your Process Cloud Provisioning Requests flow runs automatically. This flow dynamically creates the proper Cloud Instance record that is based on the requested instance type. It also generates a cloud instance URL, which populates in the Cloud Instance Provisioning Request record.