SC Orchestrator : Return data belonging to multiple activities using single activity

I have often seen requirements related to returning data using “Return Data” activity. Developers adopt different approaches for returning data. Some of them are implemented using best practices while others becomes anti-patterns. One of the requirements that often arises as follows

1. There are multiple activities within a runbook. The count could be anything beginning from 2.

2. Each activity has the potential to fail and error out.

3. The runbook should return the error if there is a failure.

The typical approach to implement the above problem looks like below..

Typical Runbook  Implementation

Typical Runbook Implementation

A closer look into the above runbook will reveal that there are multiple “return Data” activity used to return error information to the caller of this runbook; one for each activity.

The above would work as expected but definitely not the most elegant way of returning data. One of the way or pattern to handle such a situation is to use the below pattern.

Pattern for Returning Error Data

Within the above runbook, there is a single “return error” activity responsible for returning the error message for failure of any activity within the runbook. However, it raises few questions, primarily..

1. What should the published data look like within the “Return Error” activity.

2. How will “Return Error” activity know which activity has failed.

Let’s try to find out answers to above questions through step by step implementation which would also form the pattern to solve above mentioned requirements..

A. Configure the Runbook to return some data. In this case, a single “ErrorMessage” is configured for returning the error message. Refer to below image.

Configure Runbook Return Parameters

Configure Runbook Return Parameters

B. Configure the “Return Error” activity.

1. Within the return error activity, within the “Error Message” input field right click and go to published data and click on the first activity for which error data needs to be returned and also select “Show common published data”. In this case, it is Copy file activity.

Select the first activity

Select the first activity

2. Once “Show common published data” is selected, more published data is made available for usage including “Error summary text”. Select the item “Error summary text” as published data to be returned.

Select published data to return

Select published data to return

3. Repeat the above step 1 and 2 for rest of other activities for which you want to return the error message. Eventually the input field for “Error Message” should look like below.

Published data

Published data

The published data is of the form {Error summary text from activity1}{Error summary text from activity2}{Error summary text from activity3}{Error summary text from activity4}{Error summary text from activity5}. In this pattern, the error message published from each activity is placed side by side to each other.

But how does it works…

At any point of time, if there is an error in the runbook – it has to be because of failure of any one activity. The next activity executed after the  failed activity would be “Return Error” activity. within the “ErrorMessage” Parameter, only one published data out of all the five published data would be filled up with value. Rest of the published data would have null values.

One more important point to remember for the above pattern to work is that the links between the activities and “Return Error” activity must be configured as below such that the “Return Error” activity is executed only if there is a “error” or “warning” while executing the activity.

Link Configuration between activity and Return error activity

Link Configuration between activity and Return error activity

That’s it!!!! We have answered both the questions as well as developed the pattern needed to return dynamic data based on single Return data activity.

Hope you would find this articles and Post useful!