Multi-Parent Dependent Lookups
This feature uses the dependentLookupAttributes
and
lookupCode
fields to specify the dependency.
Some fields use drop-down lists to limit choices to legal values and speed data entry. The drop downs can be configured so that they depend on earlier fields in the data entry order. Such a field cannot be entered on a new record and only becomes available to enter when the fields it depends on have values. Each earlier field is considered a parent of the drop-down list. There is no limit on the number of parent fields.
We use an example that uses three fields: Country Code, Organization Type, and Organization Subtype. Organization Type is nested within country and, of course, Organization Subtype is nested within Organization Type. Of the three fields, only Country Code is enterable on a new record. The other two fields are initially non-enterable and display help text. This is shown below:
Organization Type is dependent on Country Code and will only allow data entry when the Country Code is has a valid value. When the user enters a valid Country Code, Organization Type becomes enterable.
In the following image, the Country Code has been specified and the user has selected the Organization Type for data entry. Thus, the Organization Type help text has been replaced by a drop-down list that has been populated with the values appropriate for that country.
The Country Code populates Organization Type's drop down.
When the Organization Type has been specified, the Organization Subtype drop down is populated with the correct subtypes for that organization type. Its drop down is displayed when the user selects it:
Multi-parent dependencies can be configured in this way.
The configuration uses the dependentLookupAttributes
and
lookupCode
fields to specify the dependency. Here is the code
for this example:
"attributes": {
"label": "Country Code",
"name": "CountryCode",
"type": "String",
"URI": "configuration/entityTypes/HCO/attributes/CountryCode",
"lookupCode": "COUNTRY_CD",
"dependentLookupAttributes": {
"configuration/entityTypes/HCO/attributes/TypeCode",
"configuration/entityTypes/HCO/attributes/SubTypeCode"
}
} {
"label": "Organization Type",
"name": "TypeCode",
"description": "",
"type": "String",
"URI": "configuration/entityTypes/HCO/attributes/TypeCode",
"lookupCode": "HCO_TYP_CD",
"dependentLookupAttributes": {
"configuration/entityTypes.HCO/attributes/SubTypeCode"
"
}
}
{
"label": "Organization Subtype",
"name": "SubTypeCode",
"description": "",
"type": "String",
"hidden": false,
"important": false,
"system": false,
"URI": "configuration/entityTypes/HCO/attributes/SubTypeCode",
"lookupCode": "HCO_SUBTYP_CD"
}
Lookups Definition
"COUNTRY_CD" {
"RU": {
"displayName": "Russian Federation"
},
"GB": {
"displayName": "United Kingdom"
}
}
"HCO_TYP_CD" {
"LLC": {
"displayName": "Limited Liability Company",
"parents": {
"COUNTRY_CD.RU"
}
}
"Part": {
"displayName": "Partnerships",
"parents": {
"COUNTRY_CD.RU",
"COUNTRY_CD.GB"
}
}
}
"HCO_SUBTYP_CD": {
"OTH": {
"displayName": "Others",
"parents": {
"COUNTRY_CD.GB",
"COUNTRY_CD.RU",
"HCO_TYP_CD.Part"
}
}
}