Using Automatic ID Lookup in Views

For examples of views using the Automatic ID Lookup feature, see: 

Forms

Grids

Grids with custom SQL queries

HTML charts

Cross-tables

Lookup field title 

Views determine the title of the displayed ID or lookup field using the following rules, listed from highest precedence to lowest:

lookupDisplayType

Display this field title

id

ID field

lookup

Lookup field

concatenate

ID field

Hide ID or lookup fields in specific views

You typically want the ID field hidden in reports when the lookup values are present, as the ID fields are not very useful.  By default, the ID fields would be hidden. 

However, you may not always want the ID field hidden.  For example, views that show the relationship between Employee ID and Employee Last and First Name need to show the ID.  In addition, you may want the ID field displayed in views where the ID field source table (such as, Departments) is the main table, such as the Select panel of Select-Edit views.

You may also need to hide the lookup fields.

To hide ID or lookup fields, add the lookupDisplayType attribute to the ID field in the data source. This setting overrides the displayType value in afm_flds.attributes for this specific view field.

// display the ID field, hide the Lookup field
<field name= "bl_id"  lookupDisplayType= "id" />
// hide the ID field, display the Lookup field
<field name= "bl_id"  lookupDisplayType= "lookup" />
// display both the ID field and the Lookup field
<field name= "bl_id"  lookupDisplayType= "both" />
// display the ID field value concatenated with the Lookup field value
<field name= "bl_id"  lookupDisplayType= "concatenate" />

You can specify lookupDisplayType only in the data source field, and not in the panel field. 

Override the lookup display format or sort order

To override lookup display format or sort order for specific view field, add the lookupDisplayFormat and/or lookupOrderBy attributes to the ID field in the data source:

<field name= "em_id"  lookupDisplayType= "concatenate"  lookupDisplayFormat= "{1} ({0})"  lookupOrderBy= "lookupFirst" />

You can specify lookupDisplayFormat only in the data source field, and not in the panel field.

Edit forms

There are two uses cases for data entry forms.

ID field is a foreign key

ID field is a primary key OR lookup field is explicitly defined in the form

Column reports

Column-style reports are not used alone but in Wizards and multi-pane forms (such as the Examine form of the Group Move Wizard). For column-style reports with multiple columns, inserting the lookup fields after the ID fields (when ID field is not hidden) may alter the layout significantly.

For each ID field in column report, column-style reports:

Grids and reports

For each ID field, the view:

Grid Filter

When the user filters records using mini-console, the grid filters on visible values. 

lookupDisplayType

WHERE

Comment

id

ID field LIKE '%value'

 

lookup

Lookup field LIKE '%value'

 

both

ID field LIKE '%value'

If the user entered value in the ID column.

Lookup field LIKE '%value'

If the user entered value in the Lookup column.

concatenate

(ID field LIKE '%value' OR Lookup field LIKE '%value')

 

Filter consoles always apply the restriction on the ID field, even if the grid concatenates ID and lookup values.

Grid Sort

When the user sorts records by clicking on the ID column header, the grid sorts by visible values. When lookupDisplayType=concatenate, you can optionally specify whether you want to sort first by ID value or by lookup values.

lookupDisplayType

ORDER BY

Comment

id

ID field

 

lookup

Lookup field

 

both

ID field

If the user clicks on the ID column

Lookup field

If the user clicks on the Lookup column

concatenate

ID field, Lookup field

Default, when lookupOrderBy attribute is not specified, or when lookupOrderBy=idFirst.  

Lookup field, ID field

When lookupOrderBy=lookupFirst

Grid Index

If the view defines an index field, the grid handles it as follows:

lookupDisplayType

Index by

id

ID field

lookup

Lookup field

both

ID field

concatenate

ID field

Select Values forms

Select Value forms follow the same rules as the Grid Panel, except the ID field is always visible. They ignore the above rules listed in the “Hide Numeric ID Fields” section of this topic.

If you have specified the sortFieldNames attribute, the dialog sorts by lookup and ID values. Sorting by lookup values makes the list appear correctly sorted, and sorting by ID values ensures that duplicate lookup values are consistently sorted.

If you have not specified the sortFieldNames attribute, the dialog sorts by all of the lookup fields and all ID fields. (e.g. ORDER BY dv.name, dv.dv_id, dp.name, dp.dp_id).

Auto-complete

Auto-complete displays records that match user query either in the ID field or the name field.

It displays both the ID and the lookup fields matching form fields (e.g. wr.dp_id and dp.name). 

If the foreign key is a child key of a hierarchy, such as Division-Department, auto-complete also displays parent ID and lookup values  (e.g. wr.dv_id and dv.name).

Tree control

If any of the lookup fields are already displayed in the tree, the tree displays exactly as if automatic lookup is disabled (and it does not hide ID fields per "Hide ID Fields").

If the ID field is hidden per the above rules; trees display the lookup field instead of the ID field.

If the ID field is not hidden, trees display the lookup value next to the ID field. 

The tree sorts nodes by the lookup + ID field.

Cross-tables and charts

If Automatic ID Lookup is enabled, the view:

Grouping data sources modify their queries as follows:

Data source type

Grouping fields

GROUP BY

ORDER BY

1D

rm.dp_id

rm.dp_id, dp.name

dp.name

2D

rm.dp_id, rm.bl_id

rm.dp_id, dp.name, rm.bl_id, bl.name

dp.name, bl.name

Chart data axes and cross-table calculated fields do not use lookup fields. For example, count(em.em_id) works even if the ID field is numeric.

Export to XLS, DOCX, and PDF exports the chart or cross-table with the same visible fields as rendered in the browser.  

Note: Only the HTML chart control supports ID lookup. Customers who use Flash charts can migrate them to HTML charts in order to use Numeric IDs.

Drawing labels

In drawing panels, label text for Employee, Building, Department/Division, Category/Type values by default display the ID field.

If Automatic ID Lookup is enabled, labels display ID and/or lookup values based on global per-field schema preferences and per-view overrides (same as grid reports).  

Drawing highlights

Highlight data sources that do not explicitly include lookup fields, display ID and/or look up values based on global per-field schema preferences and per-view overrides (same as grid reports).

Leaflet map control 

If Automatic ID Lookup is enabled, Leaflet map markers display lookup values based on global per-field schema preferences and per-view overrides (same as grid reports).

lookupDisplayType

Display this field value

id

The ID field.

lookup

The Lookup field.

concatenate

Not supported (displays the ID field).

both

Not supported (displays the ID field).

.      

Custom controls

Custom controls implements using Java Script or Flash, such as Flash Calendar, do not support Automatic ID Lookup at this time.

 

Copyright © 1984-2019, ARCHIBUS, Inc. All rights reserved.