Automation–Orchestrator Run .Net Script Activity–Unexpected Data Flattening Behavior Workaround

Hello Readers/Viewers!

As you saw with our post last week (Automation–An Introduction to Service Management Automation), very soon we will be providing even more guidance on the next generation of Automation for System Center: SMA. Until then, I still have a couple more Orchestrator Tips/Tricks up my sleeve – and I wanted to follow-up on my most recent post (Automation–Orchestrator Tip/Trick–Run .Net Script Activity + PowerShell + Published Data Arrays)  with more recently discovered “interesting” behavior.

So, let’s get to it!


What? More “interesting” behavior for the Run .Net Script activity?

Yes.

As we saw in the previous post, the Run .Net Script activity handles the output of array data very differently than it did in previous versions of Orchestrator/Opalis Integration Server. In fact, if you are interested, you can review its previous behavior here (my “8-Minute-Demo - OIS 6.3 - Best Practice Video Shorts - Multi-Value Data Handling”).

I recently reproduced this behavior while helping one of our internal customers of SC2012 Orchestrator, here at MSFT. Because I was surprised at the results, I felt it necessary to make more information available, especially to list the options for workaround.

The behavior

For the Run .Net Script activity, a mix of multi-value data and single value data published data output will result in data flattening (with a single space). This is not the same configurable Flatten option which exists on the Run Behavior tab of all activities. This is a separate (by design) behavior that only occurs when there is a mix of multi and single value data published data output. Because the Run .Net Script activity is 100% user configurable (published data included), the output is handled differently than other activities. For instance, if you use the Query Database activity, you know that you can have both multi-value and single value published data output (e.g. Number of Rows [single value data] vs. Full line as a string with fields separated by ';' [multi-value data]). Unfortunately, this is no longer the case for the Run .Net Script activity (from System Center 2012 Orchestrator to present).

Why does this matter?

This is only important if you want to be able to publish both multi and single value data to the databus (like the Query Database activity scenario described above). This is often the case when the published single value data is used as a semaphore in the adjacent link as a filter (e.g. If Count > 0 Continue, Else Stop). After the link filter on the single value data, the multi-value data would be leveraged accordingly. Because of the unexpected data flattening behavior in the Run .Net Script activity, the link filter on the single value data capability is either not possible or will require multiple activities to accomplish (see Workarounds section below).

REMINDER: Because the unexpected data flattening leverages a single space as the delimiter during flatten, if your data contains spaces, Option 2 Workaround is not valid.


What does this behavior look like?

The following set of screen captures will illustrate what the behavior looks like during configuration/execution.

Multi-Value Data Output Only

Configuration

image

image

Output

image

Multi-Value Data AND Single Value Data Output

Configuration

image

image

Output

image

NOTE: The flattening of the “Array Values” [multi-value data] field did not occur until the “Array Count” field [single value data] was added to the activity's configuration.

Interesting Alternate Configurations and Behavior

Working – Does not Flatten

Two Multi-Value Data Array Output (Same-Length)

image

Two Multi-Value Data Array Output (Jagged)

image

NOTE: More information about working with “Jagged” Published Data Arrays can be found here .

Non-Working – Does Flatten

Two Multi-Value Data Array Output (Jagged), Second array configured as Single-Value

image

NOTE: This would have been my suggested workaround, but obviously it suffers from the same data flattening behavior.


Workarounds

There are essentially three options to avoid inadvertently flattening your data in the Run .Net Script activity. Two of these options will allow for single value data link filtering for later use of the multi-value data.

Options

  1. [limited functionality] One Activity: Publish one set of data (multi-value data) as published data no filtering by single value data allowed.
  2. [nearly full functionality] Two Activities (with link filtering):
    • Activity One - Publish two sets of data as published data (multi-value and single value data), understand that this will flatten the multi-value data
    • Link Filter - Filter on the single value data as desired
    • Activity Two - Expand the flattened data from Activity One and re-publish the multi-value data to be leveraged in subsequent activities
      NOTE: Activity Two’s execution is dependent on the link filter configuration and data from Activity One.

Example for [nearly full functionality] (Option 2)

REMINDER: Because the unexpected data flattening leverages a single space as the delimiter during flatten, if your data contains spaces, the “expand” workaround is not valid.

Activity One Configuration

image

image

image

Activity Two Configuration

image

image

NOTE: Activity Two directly leverages the tip/trick from the previous blog post ( Automation–Orchestrator Tip/Trick–Run .Net Script Activity + PowerShell + Published Data Arrays ).

Activity One and Activity Two Output

image

Why is Option 2 [nearly full functionality]?

I list Option 2 as [nearly full functionality] on purpose. It still relies on a " " as a delimiter – which is less than ideal. So then I thought, “What if I use the built-in configurable Flatten option which exists on the Run Behavior tab of all activities?”

Unfortunately it is ignored when dealing with this type of “mixed” published data behavior. Here are my test activity configuration and output results (I slightly modified the above example for the test):

Test Configuration

image

Test Output Results

image

NOTE: The #DELIM# delimited configured to Flatten the activity data is ignored and " " remains the delimiter. So my attempt at splitting by “#DELIM#” will fail in Activity Two.

So where does that leave us?

While the [nearly full functionality] Option 2 workaround will not work for everyone, it is one way to have both single value filtering AND multi-value output as published data. Yes, it requires two activities and a link filter. Yes, it is only valid for data that doesn’t already contain spaces.

So, is there another way?

Of course! It is Orchestrator – there are many different ways to do the same thing. And luckily, I have one for this situation that makes it a bit more reliable…

Options (cont.)

      3.    [full functionality] Three Activities (with link filtering):

    • Activity One - Publish one set of data as published data (multi-value), leverage the built-in Flatten functionality
    • Activity Two - Parse and count the configured delimiter to determine array count, return as single value published data output
    • Link Filter - Filter on the single value data as desired
    • Activity Three - Expand the flattened data from Activity One and re-publish the multi-value data to be leveraged in subsequent activities
      NOTE: Activity Three’s execution is dependent on the link filter configuration and data from Activity One and Activity Two.

Example for [full functionality] Option 3

Activity One Configuration

image

image

image

Activity Two Configuration

image

image

image

Activity Three Configuration

image

image

NOTE: Activity Three directly leverages the tip/trick from the previous blog post ( Automation–Orchestrator Tip/Trick–Run .Net Script Activity + PowerShell + Published Data Arrays ).

Activity One, Activity Two, and Activity Three Output

image


Conclusion

If any of this information fits your scenario, great. If not, then at the very least you won’t have to continue wondering why your data is being flattened.

For more information and tips/tricks for Orchestrator, be sure to watch for blog posts in the Automation Track!

enJOY!