What is the best way to find item in array

What is the best way to find item in array
neil_rogers's picture

I have an array that has 150 computers and guids in it. Computers_result[*].guid and Computers_result[*].name. I want to find the guid for the computer named NSbox. I can loop through the array and remove one at a time with a "Get Item from Index", and an equals rule, set it to a variable for the next step, but seems like there should be a component that will loop through an array or a different way to handle finding what the guid is.

Neil Rogers

Configurable Collection Filter

rhamner's picture

The component you're looking for is Configurable Collection Filter. First you specify the data type, input array variable, and whether you want to create a new variable with the result or remove the filtered items from your input variable. Next you have a Filter Model that is run on each item in the array where you can put your logic of whether to keep the item or not. In this model you have a special variable called Element that is the current item in the array that is being tested. In your case you would use a Text Equals Rule and your Compare Variable would be something like Element.name.

how i solved it

neil_rogers's picture

This is what i used to solve my problem.

http://juice.altiris.com/tip/5246/collections-and-...