Using Automatic ID Lookup in Custom Code

Java API

To check whether Automatic ID Lookup is enabled for the current project:

ContextStore.get().getProject().isIdLookupEnabled()

To find the lookup information for an ID field:

ContextStore.get().getProject().loadTableDef(tableName).findField(fieldName).getLookupFieldMapping();

The LookupFieldMapping class provides information about lookup field for specified ID field. See Javadocs for details.

Java Script API

You can use JavaScript API to retrieve Lookup metadata for specified ID field, and to format the ID/Lookup values: 

var idFieldDef =  this .propertyDataSource.fieldDefs.get( 'pr.pr_id' );
idFieldDef.lookupName;  // returns 'pr.name'
idFieldDef.lookupDisplayType;  // returns 'lookup'
idFieldDef.lookupDisplayFormat;  // returns '{0} - {1}' 
var formattedValue =  this .propertyDataSource.formatLookupValue( 'pr.pr_id' ,  'BOS' , recordValues);  // returns 'Boston' 

 

 

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