How to store workitem objects in an array in powershell ?
Probably quite a basic question, but I'm struggling to find the right syntax. In my workflow I retrieve a few workitem objects that I want to reference later (to create child activities in them). How can I create an array, list or hashtable that contains a string as name to identify the item and a workitem object as value ?
So for example I have a SR that is for IT that I would like to reference like $ParentItem = $Items("IT").WorkItem and then create child objects in that $parentItem, where "IT" can be another string to identify an SR in another support group's queue
such as $ParentItem = $Items("HR").WorkItem
I know how to retrieve the workitems, but I can't get my head around the syntax of how to stuff it in the array.
Answers
So first you initialize a null array. Then you get your Work Item objects, for simplicity sake I went with any Incident created after August 1st. Then for-each Work Item retrieved, add it into the array using the +=. The array is now "loaded" so to speak with Incident objects that can be individually addressed, iterated through, and further properties retrieved on them.
The array could then be addressed like:
$array[0]
This represents the first Incident object in the array.
$array[0].Title
Represents the first Incident object's Title in the array, etc. etc. Which means you could now while loop this and do something like: