Skip navigation
All Places > Getting Started > Blog > Authors paul.crawford

Getting Started

2 Posts authored by: paul.crawford Champion
paul.crawford

Collection Operations

Posted by paul.crawford Champion May 26, 2016

After creating this blog post Collection Operation - Get , i thought it would be good to look at the other Collection Operations in some detail too.

As stated in the article above, the Collection Operation action allows you to interact with a Collection Variable. This can be useful in many situations.

 

Add

This method allows you to add to a value at a specific index within a collection

Original Collection - Audi; BMW; Volkswagen

Value to add - Mercedes

Index - 2

Resulting Collection - Audi; BMW; Mercedes, Volkswagen

 

Remove

This method allows you to remove a value from a specific index within a collection

Original Collection - Audi; BMW; Volkswagen

Value to Remove - BMW

Index - 1

Resulting Collection - Audi; Volkswagen

 

Count

This method allows you to count the number of items in a collection

Original Collection - Audi; BMW; Volkswagen

Result - 3

 

Get

This method allows you to get a value from a specific index within a collection

Original Collection - Audi; BMW; Volkswagen

Index - 1

Result - BMW

 

Exists

This method returns the index of a value within a collection if the value is in the collection, returns null if the value doesn't exist

Original Collection - Audi; BMW; Volkswagen

Value - Audi

Result - 0

Original Collection - Audi; BMW; Volkswagen

Value - Mercedes

Result -

 

Sort

This method sorts the items in a collection

Original Collection - Audi; BMW; Volkswagen

Order - Ascending

Result - Audi; BMW; Volkswagen

Order - Descending

Result - Volkswagen; BMW; Audi

 

Pop

This method returns the last value in a collection

Original Collection - Audi; BMW; Volkswagen

Result - Volkswagen

Resulting Collection - Audi; BMW

 

Join

This method joins all the values in a collection with a specified delimiter and stores in a variable (not a collection variable)

Original Collection - Audi; BMW; Volkswagen

Delimiter - ,

Result - Audi, BMW, Volkswagen

 

Clear

This method clears all items in a collection

Original Collection - Audi; BMW; Volkswagen

Result -

 

Remove Duplicates

This method allows you to remove duplicate items in a collection

Original Collection - Audi; BMW; BMW; Volkswagen

Resulting Collection - Audi; BMW; Volkswagen

 

Remove by Value

This method allows you to remove items from a collection if the value exists. If the value doesn't exist the original collection is returned

Original Collection - Audi; BMW; Volkswagen

Value - BMW

Resulting Collection - Audi; Volkswagen

Original Collection - Audi; BMW; Volkswagen

Value - Mercedes

Resulting Collection - Audi; BMW; Volkswagen

 

Have fun with collections!!!

I was asked this question by Daniel Mueller and thought it was worth sharing

 

I have a string stored in a variable looking like this: name, email, username

I'm using the regular expression to split the string and storing the result in a collection variable (lets name it collection).

So from my understanding it should look like this now:

collection[0] = name

collection[1] = email

collection[2] = username

 

So I only want to use the second variable (email) in that collection and put it into an email field for example how do I do that?

From my understanding there must be something like this: ID1 collection but I dont know how to extract that.

 

Isn't the collection an array of variables?

 

I read the whole guide of "how to use a collection" but this didnt answer my question.

 

The Collection Operation action allows you to interact with a Collection Variable and specifically the Get operation allows you to access a specific index of that collection. In Daniel Mueller case the second index.

 

If the second index of your array is always the email, create a number variable with a default value of 1.

Capture.PNG

Then add a collection operation configured as below

Capture.PNG

This will then store the email address in the vTextEmail variable and you can now use this as you need.

 

All that would need to change would be the value set in the first vNumIndex variable to get the index of the collection required.

 

This document was generated from the following discussion: Collection variable get specific item

Filter Blog

By date: By tag: