Returns the index associated to an SDT item in an SDT collection.
&VarBasedOnSDTCollection.IndexOf(&VarBasedOnSDTItem)
Where:
&VarBasedOnSDTCollection
It must be a variable based on an SDT collection (or a variable based on a simple SDT and defined as a collection).
&VarBasedOnSDTItem
Variable based on an SDT item.
Generators:
.NET,
.NET Framework,
Java, Ruby (up to GeneXus X Evolution 3)
It returns the index (a numeric value) associated with the Item parameter element of an SDT collection.
In general, the IndexOf method of an SDT Collection is used in conjunction with the Remove method. Once you have the desired index (position in the SDT), you can use the associated Remove method.
&index = &sdtCollection.IndexOf(&sdtCollection.CurrentItem)
&sdtCollection.Remove(&index)
This method works with the elements' references and not with their contents. This implies that if a variable with a list of SDT is received as a parameter and a temporary variable is loaded with an item content, IndexOf will return 0 (empty) since this reference is not within the list. It can be useful only in the moment the list is loaded.
Structured Data Type methods