I saw a question in the forums around multi-value data and how someone could pass multi-value data in to a runbook via the Initialize Data activity. I was going to answer the question there but thought it would be better to post an article to reach a broader audience. When dealing with published data on the databus, it’s helpful to know exactly how multi-value data is produced and consumed so you can plan your runbooks accordingly. Actually, it’s kind of simple once you understand it.
First of all, when I say multi-value data, the term refers to multiple occurrences of an activity’s property or properties. You can think of this as a table, an array, or a collection, whatever suits you best. For example, if you ran the PowerShell command:
You would get back a collection of objects, each with several properties. This is multi-value data. You can handle multi-value data in two ways: (1) You can leave it as it is in “collection” form (which is the default behavior), or you can (2) flatten it into a long string of delimited values (like a comma-delimited list).
The way you choose to handle multi-value affects the way the subsequent activities in the runbook are run. If you choose the default behavior, then the next activity will be run one time for each “row” in the data. If you choose to flatten the multi-value data, then the next activity only runs once, but usually you’ll have to do your own parsing of the data to pull out relevant values.
Now here’s the important part: multi-value data exists only in the activity that created it. Huh? What does that mean? It means that when an activity is triggered, it is triggered by a single instance of the data generated from an activity. Multi-value data in its true “collection” form is never sent to an activity. The next activity is triggered with a single value of that multi-value data. Therefore, the only way to pass in an entire collection of data is to have it flattened in some form first. There is no way to pass in an existing collection of multi-value data because every activity expects to receive a single item.