Reusing Workflows

Reusing Workflows

 

There are 3 ways to reuse a Workflow:

You need to…

Apply this method

Incidentally reuse a limited set of Activities.

Select the Activities, copy them, then open the target Workflow, and paste.

Frequently reuse the same Workflow, or reuse the same part of a Workflow.

Add the Workflow to the Child Workflow Projects folder.

Frequently create Workflows that follow the same structure, but that are tailored to each situation.

Create a Workflow template, then reuse the template.

 

Reuse a set of Activities

As explained, you can select Activities and simply copy them to a different Workflow within the same Solution.

In case you want to a set of Activities to a different Solution:

  1. Open up a second Workflow Studio.
  2. Copy the Resources from the original Solution to the targeted Solutions folder.
  3. Copy the Activities as explained earlier.

 

With this method you will have to recreate any variables in the target Workflow, as it will not copy variables.

 

Reuse the same (part of a) Workflow, including its settings

In case you frequently use the exact same Workflow with the exact same settings, or often reuse the same set of Activities with the same setting across many Projects or Workflows, an efficient way of working is to save that (part of a) Workflow to a Child Workflow Project.

Child Workflows are useful if many of your Workflows require parts that are consistent and identical across all Workflows. You can reuse a Child Workflow just like an Activity.

These are the steps to create a Child Workflow:

  1. Create a Project for Child Workflows. It should only contain reusable Workflows.
  2. Add reusable Workflows to the Project.
  3. When done, go to the Solution Explorer, hold the Shift key, and drag the Project to the Child Workflow Projects folder.
  4. Build the Solution ( Ctrl + Shift + B ).

Your Child Workflows will appear in the Toolbox, ready for reuse. You can reuse these Workflows across all Projects in the same Solution, just like an Activity. In fact, any reused Workflow will get a CurrentDocument property and the option to use Arguments, just as with Activities.

While a reusable Workflow can be very efficient, it does introduce dependencies:

  • Changes in a Child Workflow will be reflected everywhere where that Child Workflow is in use.
  • Do not rename a Child Workflow that is in use. It will break references to that Workflow.
  • Do not delete a Child Workflow that is in use. It will break references to that Workflow.

Tips for working with Child Workflows:

  • Keep reusable Workflows generic.
  • It is easier to reuse parts of a Workflow, instead of a whole Workflow.
  • When adding a Child Workflow to another Workflow, place them into a TryCatch Activity. This way, you can catch errors that the Child Workflow causes.

     Read more

    You do not need TryCatch if you use the ExecuteReprocessableWorkflow activity which is implicitly also a try-catch.

    The TryCatch handles errors, but also emits a separate processing state from which the document can be reprocessed through the SmartBridge UI from the point where the child workflow started the execution.

    A TryCatch is especially useful if this is used in a “for each” loop processing a set of child documents: Would an error occur while processing one of the child documents with such a child workflow, the parent workflow is then able to continue with the next child document in the list (hence try-catch), and also creates states for each child document separately. This enables you to reprocess only those child documents which went wrong.

  • If you want to remove a Child Workflow from the Toolbox, use the Solution Explorer: Hold the Shift key and drag the Workflow to a non-Child Workflow Project.
  • As a safeguard, the Toolbox will not display the Child Workflow that you are currently editing. This way, it will not be possible to create infinite loops with the same Workflow.

 

Reusing Workflows with Workflow templates

Workflow templates save you a lot of time when you are regularly creating the same Workflows but with different settings.

  1. Create a generic Workflow, omitting situation-specific settings.
  2. Build it ( Ctrl + Shift + B ).
  3. Export the template, using the main menu: File > Export template…. A wizard will open.
  4. In the wizard, select ‘Item template’, indicate the Project containing the Workflow, and click Next.
  5. Indicate the item to export, and click Finish.

This will create a file that you can reuse across Projects.

Importing a Workflow template

  1. In the main menu, go to File > Open > New item….
  2. Locate your Workflow template file, double-click it, and confirm.