cancel
Showing results for 
Search instead for 
Did you mean: 

All PropertyBag values to Diag Console?

Thy_Toeung1
Champ on-the-rise
Champ on-the-rise

Is it possible to iterate through the Session Property Bag in a Unity Automation script, outputting each key/value pair to the diagnostic console? I am troubleshooting a workflow with several propertybag pairs. If there was a way to iterate and loop through the pairs, then I could reuse the code in other troubleshooting efforts.

As it stands, I will have to specifically spell out each key that I know of.

Thy

1 REPLY 1

Brian_Koning
Star Contributor
Star Contributor

Hello Thy,

I apologize for the delay in our response to your question. It is quite a good question and it would be useful to answer for others who have the same question.

The Hyland.Unity.Workflow.PropertyBag class implements many of the generic collection interfaces to allow you better access to the data contained within. Of particular interest is the IEnumerable and IEnumerable<KeyValuePair<string, object>> interface implementations by the PropertyBag. You would iterate through all of the values contained within a PropertyBag instance with a foreach loop:

foreach (KeyValuePair<string, object> pair in propertyBag){  app.Diagnostics.Write(string.Concat("PropertyBag Value: ", pair.Key, " = ", pair.Value.ToString()));}

The ability to iterate through the PropertyBag should only be used in OnBase 12 and later. Unity Scripts which use this functionality before then will see a Serialization exception thrown by Workflow and their Unity Script will stop execution.