Method: Sources.Find( … )
Use for fast performance lookup of values from other Table Data Sources.
Returns the row from the specified data source with the specified key-value.
The method can only be used on table data sources that have a unique key column as their first row, such as returned by the SELECT.UNIQUE Command.
The advantage of using this method is its fast performance on finding items in large data sources, e.g. if you need to lookup product items from a large list of Item numbers or similar.
Syntax
DataRow Sources.Find( string sourceName, object keyValue )
Method Parameters
string | Name of the Data Source to search in. |
object | A keyValue to search for by the unique column in the Table data source. |
Example
Below example shows how to lookup values fast in a lookup table in order to convert supplier Item Numbers to My Item Numbers
In below example a data source named SupplierItemNumbers contains a translation table with 2 columns named SupplierItemNo and MyItemNumber. In below example it is assumed that the script is setup on a map-entry that delivers a Supplier Item Number in the Value property. A new value is looked up by using the Value as keyValue to find the matching MyItemNumber value.
// SupplierItemNumbers contains lookup-table with SupplierItemNo and MyItemNumber
// Input-Value contains SupplierItemNo
if( !HasValue ) return;
var lookup = Sources.Find( "SupplierItemNumbers", Value );
if( lookup != null )
Value = lookup["MyItemNumber"];