Get Item Index

Verb: indexOf

Gets the index of an item in a given List. The index corresponds to the item's position on the list.

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


indexOf --value(Variant) --collection(List<Variant>) (Numeric)=value


Script Designer Required AcceptedTypes Description
--value Item Required Any Item of which the index should be obtained in the List.
--collection List Required List<Any> List from which the desired item's index should be obtained.


Script Designer AcceptedTypes Description
value Index Number Index of the item.


Gets the index of the item inserted in the Item parameter and stores it in a variable.

defVar --name namesCollection --type List --innertype String --value "[Ana,Mary,Lucas,Victor]"
defVar --name itemIndex --type Numeric
indexOf --value Lucas --collection "${namesCollection}" itemIndex=value
logMessage --message "${itemIndex}" --type "Info"
//The result obtained in ${itemIndex} is: 3.

See Also

  • Copy List with Restrictions
  • Insert Item into List
  • Remove From List
  • Remove Value