Lookups
Basic, polymorphic, and cascading lookups with display fields, filters, and advanced configuration.
Lookup Reference
Lookups create relationships between objects. They're the relational backbone of your P9 data model.
Basic Lookup
A simple reference to another object:
field Customer type:Lookup label:"Customer" required:true
lookup Customer {
lookupobjectname:"Account"
displayfield {
"Name"
"Number"
}
}
This creates a searchable dropdown that references the Account object, displaying the Name and Number fields.
Display Fields
Control what's shown in the lookup dropdown:
lookup Customer {
lookupobjectname:"Account"
displayfield {
"CompanyName"
"AccountNumber"
"City"
}
}
Multiple display fields show as columns in the lookup search results.
Filtered Lookups
Restrict available options based on conditions:
lookup AssignedTechnician {
lookupobjectname:"Employee"
displayfield {
"Name"
"Department"
}
filter {
Role="Technician"
Status="Active"
}
}
Lookup with Allow Multiple
Allow selecting multiple records:
field Tags type:Lookup label:"Tags" optional:true
lookup Tags {
lookupobjectname:"Tag"
displayfield {
"Name"
}
allowmultiple:true
}
Cascading Lookups
Create dependent lookups where one filters another using parent and parents blocks:
field Country type:Lookup label:"Country" required:true
lookup Country {
lookupobjectname:"Country"
displayfield {
"Name"
}
}
field City type:Lookup label:"City" required:true parent:Country
lookup City {
lookupobjectname:"City"
displayfield {
"Name"
}
parents {
Country {
parentobjectfield: "Country"
}
}
}
field District type:Lookup label:"District" optional:true parent:City
lookup District {
lookupobjectname:"District"
displayfield {
"Name"
}
parents {
City {
parentobjectfield: "City"
}
}
}
When the user selects a Country, the City dropdown automatically filters to show only cities in that country.
Building-Floor-Unit Cascade Example
field Building type:Lookup label:"Building" required:true linked-view:true advance-search:true
lookup Building {
lookupobjectname:"Building"
displayfield {
"Name"
"Number"
}
filter {
Status="Active"
}
}
field Floor type:Lookup label:"Floor" optional:true parent:Building
lookup Floor {
lookupobjectname:"Floor"
displayfield {
"Number"
"Name"
}
parents {
Building {
parentobjectfield: "Building"
}
}
}
field Unit type:Lookup label:"Unit" required:true parent:Building
lookup Unit {
lookupobjectname:"Unit"
displayfield {
"Number"
"Floor"
"Status"
}
parents {
Building {
parentobjectfield: "Building"
}
}
filter {
Status in "Available,Reserved"
}
}
Polymorphic Lookups
Reference multiple object types with a single field:
field RelatedTo type:Polymorphic label:"Related To" optional:true
polymorphic RelatedTo {
default: "Contract"
lookups {
lookup Contract {
lookupobjectname: "Contract"
label:"Contract"
displayfield {
"Number"
"Tenant"
}
filter {
Status="Active"
}
}
lookup WorkOrder {
lookupobjectname: "WorkOrder"
label:"Work Order"
displayfield {
"Number"
"Status"
}
}
lookup Invoice {
lookupobjectname: "Invoice"
label:"Invoice"
displayfield {
"Number"
"Total"
}
}
lookup Tenant {
lookupobjectname: "Tenant"
label:"Tenant"
displayfield {
"Name"
"Number"
}
show:['Leasing' in Company.Modules]
}
}
}
The user first selects the object type, then searches within that object. Polymorphic lookups are useful for:
- Activity logs that can be linked to any record
- Notes and comments on any object
- File attachments shared across modules
- Payments that can apply to different document types
Conditional Polymorphic Options
Show/hide polymorphic options based on company modules:
polymorphic Payee {
default: "Supplier"
lookups {
lookup Tenant {
lookupobjectname: "Tenant"
label:"Tenant"
displayfield {
"Name"
"Number"
}
filter {
Status="Active"
}
show:['Leasing' in Company.Modules]
}
lookup Supplier {
lookupobjectname: "Supplier"
label:"Supplier"
displayfield {
"Name"
"Number"
}
filter {
Status="Active"
}
}
lookup Employee {
lookupobjectname: "Employee"
label:"Employee"
displayfield {
"Name"
"Number"
}
filter {
Status="Active"
}
}
}
}
Self-Referencing Lookups
Objects can reference themselves for hierarchical data:
@object CostCenter
field Name type:Text label:"Name" required:true
field ParentCostCenter type:Lookup label:"Parent" optional:true
lookup ParentCostCenter {
lookupobjectname:"CostCenter"
displayfield {
"Name"
"Code"
}
}
Linked View Navigation
Enable navigation from the parent record to view all related child records:
field Building type:Lookup label:"Building" required:true linked-view:true advance-search:true
lookup Building {
lookupobjectname:"Building"
displayfield {
"Name"
"Number"
}
}
The linked-view:true attribute allows users to click through and see all records that reference a particular Building.
Lookup in Table Details
Define lookups within table detail blocks:
tabledetail LineItems {
field Product ischild type:Lookup label:"Product" required:true
field Quantity ischild type:Number label:"Qty" required:true
field UnitPrice ischild type:Money label:"Unit Price" required:true
lookup Product {
lookupobjectname:"Product"
displayfield {
"Name"
"SKU"
"UnitPrice"
}
filter {
Status="Active"
}
}
}
Lookup Behavior Summary
| Feature | Description |
|---|---|
| Search | Type-ahead search across display fields |
| Create inline | Option to create a new record without leaving the form |
| Clear | Nullable lookups can be cleared |
| Navigation | Click through to view the referenced record |
| Linked view | View all records that reference this record |
| Cascading | Dependent filtering based on parent selections |
| Multi-select | Select multiple records with allowmultiple:true |