Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

How to update the content of an existing collection

Created: 17 May 2013 | 3 comments

I have a situation where I need to combine the content of two separate collections, of different data types, into a single collection that is of a third data type.  I can loop through the first collection building entries in the target collection.  After that I loop through the second collection using the Item In Collection component to find a match on the key field.  At this point how can I copy data from the second collection to the appropriate row in the target collection?

Operating Systems:

Comments 3 CommentsJump to latest comment

reecardo's picture

Here's a brute-force method:

1st introduce a array indexer (type int, set to 0), a 1st array (type text, elements a,b,c), a 2nd array (type text, elements d,e,f), and a 3rd array (type text, null)

Loop through the array from 0->1st array.Count -1. This is done below using a Compare Numbers Rule, comparing array indexer to array.Count. If Less Than, enter the loop. If Greater Than or Equl To, go to End.

In the loop, fetch the elements of the 1st and 2nd array using Get Item By Index component (specifying array indexer as the index to get). In my example I then merge these 2 values with a Merge Text component.

Finally in the loop, I add the merged field to my 3rd array using an Add Items to Collection component. Then I make sure to increment my array indexer by 1 using an Add Values component (cut off in the pic below)

At the end, my 3rd array has elements ad, be, cf... this is a small example, but it should help you out.

coll.png

 

M Rutledge's picture

I can't rely on both input collections being the same size so I couldn't use the solution you described above.  However, I did use the Index Of Item In Collection and the Get Item By Index components to resolve my issue.

I have two input collections that contain the name of a computer and the last date and inventory was received.  One collection is populated with Altiris information and the other with data from HP Asset Manager.  The output collection contains the computer name and the two inventory dates, where available. 

I first populate the output collection with the data from Asset Manager.  I then loop through the collection of Altiris data.  For each entry I use the Index Of Item In Collection to find the corresponding entry in the output collection.  If it exists, I use the Get Item By Index component to retrieve it for update.  If it doesn't exist I create a new entry and add it to the output collection.

Thanks for your help.

 

AttachmentSize
Update a Collection.docx 129.93 KB
rpoag's picture

Have you figured this out yet? There are two components which may help you called Add Inclusions Component and Update Collections Component. The first component requires a collection/filter guid and a resource guid where the second just requires an array of collection/filter guids. I haven't fully determined how these work i.e. whether the update collection component is actually needed to commit changes but it sounds like these may help you get where you want to be. Of course you will need to get the guid of the resources in question but there is a get resource component which will get that for you if you don't want to write your own query. Writing your own query to get the guid will actually perform better since you don't need any extra data class information. Let me know if that helps.

Ryan Poag
Northrop Grumman
If your question has been resolved, please be sure to "Mark as Solution"! Thank you.