Remove Items from Collection

Verb: clear

Removes all items from a "List", "Stack" or "Queue" type collection, or from a "Message Queue".

Collections are enumerable data structures that can be accessed using indexes and keys.

Syntax

clear --collection(ICollection<Variant>)

Inputs

Script Designer Required AcceptedTypes Description
--collection Collection Required ICollection<Any> Collection or "Message Queue" in which items are removed.
In this parameter, in addition to collections of the "List", "Stack" and "Queue" type, the "Message Queue" type, originating from the connection with a queue provider, is also accepted. Thus, to manipulate a variable of type “Message Queue”, it must be obtained from the parameter Queue Obtained of the command Get Queue.

Example

Example 1: The Remove Items from Collection command removes all items contained in a collection of the "Queue" type, returning it empty.

defVar --name itensToRemove --type Queue --innertype String --value "[Maria,Ana,Lucas,Bruno]"
clear --collection "${itensToRemove}"
logMessage --message "${itensToRemove}" --type "Info"
// The result returns an empty "Queue" collection.

Example 2: The Remove Items from Collection command removes all items contained in a collection of the "Message Queue" type, obtained previously by the Get Queue command, returning it empty.

defVar --name connection --type QueueConnection
defVar --name obtainedQueue --type MessageQueue
defVar --name dsdsd --type Queue --innertype String
defVar --name itemsQuantity --type Numeric
connectActiveMQ --queueprovider Training --fromconfiguration  connection=value
getQueue --connection ${connection} --fromconfiguration  --queue queueA obtainedQueue=value
clear --collection "${obtainedQueue}"

See Also

  • Count Items
  • Get List Item