With this function it is possible to lookup a value from a specific field in another table. The lookup can be set up to query data from both source ('SOURCEDS') and destination ('DESTDS'). When building a lookup, you need to make sure that there is a common identifier/denominator between the selected tables.
"1. DataSource"
"2. TableName"
"3. KeyField-1", "KeyValue-1"
"4. KeyField-n", "KeyValue-n"
"5. ResultFieldName"
"6. Return value"
When a Transfer is running, it will collect some statistics values for the use of the DBLookup function. This statistics is shown on the console and also in the Log after the Transfer finishes.
The statistics for using a DBLookup could look like this:
DBLookup Statistics for SOURCEDS+Salesperson_Purchaser+Code: Fields 1, Total Lookups 10, DB Fetch 3 (00:00:01-234), Cache 3 (00:00:00-200)
which means that there is 1 field retrieved by this DBLookup, the DBLookup formula was called 10 times in total, it resultet in 3 lookups to the database (which took a total time of 1 second and 234 thousands of a second) and finally that the DBLookup cache contained 3 values when the transfer finished (and that querries to the cache took a total of 0 seconds and 200 thousands of a second). That the cache contains 3 records indicates that the DBLookup was called with just 3 different values (in this case 3 different Salesperson codes).
This Statistics feature is available in version 4.0.01g of the central Rapidi version.
DBLOOKUP('SOURCEDS', 'CompanyInfo', 'Name')
Return value: This will return the first record (in database specific order) in the CompanyInfo table. The data source would be the source system, the table name would be 'CompanyInfo' and the field from that table would be 'Name'.
It can be used when there is only one record in a table, for example to lookup some configuration parameters.
DBLOOKUP('DESTDS','Salesperson/Purchaser','ExternalID',"OwnerID",'Code')
This formula could be used on a Account/Customer Transfer from Salesforce.com to MS Dynamics NAV. This lookup will do the following: perform a lookup in the destination system ('DESTDS') where the table name is 'Salesperson/Purchaser', the field name is ''ExternalID'. This field from the destination system is matched with the field 'OwnerID' which needs to exist in the source system ( since formulas are always created on the left side in Field List Mapping). Note: This field will always be listed with double quotation marks. And the lookup result between the 'ExternalID' and 'OwnerID', you will get the field value for 'Code.
DBLOOKUP('SOURCEDS','orders','orderid',id,'caseid','##caseid is not null','caseid')
This formula will do a DBLookup in the table "orders" with a WHERE clause like "(orderid = ) AND (caseid is not null)". It will return the value of the caseid field.
IF(EQUALS(DBLookup('DESTDS','RapidiContactBusinessRelations','Link_to_Table','1','No',DBLOOKUP('SOURCEDS','account','accountid',"_parentcustomerid_value",'accountnumber'),'Contact_No'),''),ERROR('Account does not have a related NAV company contact:'+"_parentcustomerid_value"),DBLookup('DESTDS','RapidiContactBusinessRelations','Link_to_Table','1','No',DBLOOKUP('SOURCEDS','account','accountid',"_parentcustomerid_value",'accountnumber'),'Contact_No'))
This formula is a nested lookup that will do the following: look for the 'No' field in the table ,'RapidiContactBusinessRelations' where 'Link to Table=1'. Then, the result of this lookup will be matched with the second lookup ( which will look for the 'accountid' from the 'account' table, match it with the '_parentcustomerid_value' and get the 'accountnumber'.) and this would translate into 'No'='accountnumber'.If they match, then the lookup result will be the value from 'Contact_No'. If there is no match or it's empty, an error will be thrown.