Search these areas:
Support Forums
Product Info

DataWeb: What's New
Creating an Application
The DataWeb Designer
Application Management
Data Tables
Understanding Data Tables
Creating a New Data Table
Adding Fields to a Data Table
Specifying a Primary Key
Linking Tables with Lookup Fields
-Understanding Lookup Fields
-Creating a Lookup Field
-Accessing Data in Lookup Fields
Modifying a Field's Definition
Merging Tables with Data Transfer
Removing a Data Table
Data Tables
Data Analysis
Object Model
Full-Text Search
Domain and Email Hosting
HotBlock Modules
Account Management
New Responsive UI Module

DataWeb Help
Support Forums
Script Library
Knowledge Base

Home > Support

DataWeb User's Guide

Accessing Data in Lookup Fields
Script objects

When a script object, such as a Resultset or cmdSelect object, retreives data from a lookup field, the values retrieved are numeric pointers to other records. To retrieve a lookup field's display field, rather than the numeric pointer, use the following syntax:


where the LookupFieldName is the name of the lookup field which holds the numeric pointers, and the DisplayFieldName is the name of a field in the target table.

For example, suppose the Suppliers table has a RowId field that's an integer primary key and a SupplierName field that's a text field. Also suppose the Products table has a lookup field named SupplierLookup that stores the value of the Suppliers table's RowId field, and displays the value of the SupplierName field. If you want a Resultset on the Products table that returns the display value of the SupplierLookup field, you can create the Resultset as follows:  

var rs = new Resultset("Products", "ProductName, SupplierLookup:SupplierName", "*");

Note the special naming syntax that we use to refer to the SupplierLookup field -- "SupplierLookup:SupplierName". The first part is the name of the lookup field in the Products table, SupplierLookup. The second part is the name of a field from the Suppliers table, in this case SupplierName.

You can retrieve more than one field from the lookup table as follows:

var rs = new Resultset("Products", "ProductName, SupplierLookup:SupplierName,ContactName,Address", "*");

You can use this combination syntax anywhere you refer to a field name. For example, you can use it to retrieve the field's value from the Resultset:



On a view, if the lookup field is included within the data region, then you can use the same syntax with the record object to retrieve the display value of the lookup field. For example, if the SupplierLookup field is in the data region, you can access the display value as shown:



Data classes

The record object is also passed as an argument to the data class scripts (e.g., the BeforeInsert and AfterInsert functions, etc.). Within these functions, the record object provides only the stored value of the lookup field on the table. If you need to retrieve the display value, you should create another Resultset on the lookup table, filtering for the record that you need.

Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
Email Us