findValue

Object dataSet.findValue ( String valueToFind, String columnToMatch, String columnToReturn )

Description

Retrieve a field's value in a data set based on another field.

Parameters

  • valueToFind Value being looked for, as a string.
  • columnToMatch Column/token name where the value is being searched for, as a string.
  • columnToReturn Column/token name whose value should be returned, as a string.

Return Values

Returns the value in the returned column, usually a string (unless records have been manually added). If no match is found, null is returned.

Change Log

Version Description
5.0 Added for all editions.

Examples

Get Value of Token based on Another Token

 // Create new DataSet
 DataSet myDataSet = new DataSet();

 // Create DataRecords<
 DataRecord john = new DataRecord();
 john.put("FIRST_NAME", "John");
 john.put("LAST_NAME", "Doe");

 DataRecord jill = new DataRecord();
 jill.put("FIRST_NAME", "Jill");
 jill.put("LAST_NAME", "Smith");

 // Add dataRecords to dataSet
 myDataSet.addDataRecord(john);
 myDataSet.addDataRecord(jill);

 // Search dataSet for "John" in the "FIRST_NAME"
 // field. Return the value of the "LAST_NAME" in
 // the same record
 String result = myDataSet.findValue("John", "FIRST_NAME", "LAST_NAME");

 // Write result to log
 session.log(result); // Logs "Doe"

See Also

  • get() [dataSet] - Get a single piece of data held by a DataRecord in the DataSet.