About Subroutines

A subroutine is a workflow that you can call from multiple orchestration workflows. Subroutines can contain any orchestration elements, such as the Calculate step, and are useful when your orchestrations contain common actions. Once you have created a subroutine, you can use it by dragging it from the Step Palette into an orchestration workflow.

You can define inputs for a subroutine workflow, similar to defining Working Data, and you can define outputs for a subroutine in the Data Mapping tab of the End step.

Like Web services, you can then map these inputs within the calling orchestration to the appropriate source elements. You can use outputs in mapping and expressions of other steps.

Note the following points about subroutines:


This simple example demonstrates how to create a subroutine that appends the text "-subroutine" to a field.
  1. Create an application process app and add a new text field called Text1.
  2. In the application workflow, create a quick transition called Test Subroutine that starts and ends at the New state.
  3. Add an action to the Test Subroutine transition that does the following:
    • Calls a new synchronous orchestration before the transition occurs
    • Includes Text1 as a field that is used and returned by the event
  4. In app explorer, right-click Orchestration Workflows and select Add New Subroutine.
  5. Change the default name to AppendTextSubroutine.
  6. From the Step Palette, drag a Calculate step to the subroutine.
  7. Select the subroutine workflow. For the data mapping inputs, add the string InText1.
  8. Select the End step. For the data mapping outputs, add the string OutText1.
  9. Select the Calculate step, and create a new assignment with the following values:
    • Target: OutText1
    • Expression: CONCAT(InText1, "-subroutine")
  10. Select the orchestration you created in step 2.
  11. Drag the new subroutine step AppendTextSubroutine to the orchestration.
  12. Select the subroutine step and map the InText1 input to the following source:


  13. Select the End step and map the Text1 output to the following source:


  14. Save and deploy the process app.

To test in SBM Work Center, submit a new item and then click the Test Subroutine button. The Text1 field should display the following: