Configuring Inter-Field Dependencies
To configure inter-field dependencies:
1. In
Max Designer, on the
Developer Tools (
) launchpad menu, click
Objects, and then in the list view, locate and open an object that has
Relationship fields for which you want to specify dependencies.
2. On the record page, in the
Code tab, in the
Inter-Field Dependencies field, specify dependencies in valid JSON code, and then in the top left corner, click
Save and Close (
).
3. On the
Development Actions (
) launchpad menu, click
Synchronize.
Dependency Examples
These examples are for a scenario where the following objects and fields are created.
Object | Field | Field Full Identifier | Field Data Type | Target Object | Relationship Full Identifier |
---|
Customer | Name | dev_name | String | N/A | N/A |
Country | dev_country | Relationship | Country | dev_customer_country |
City | dev_city | Relationship | City | dev_customer_city |
Country | Name | dev_name | String | N/A | N/A |
City | Name | dev_name | String | N/A | N/A |
Country | dev_country | Relationship | Country | dev_city_country |
requiredFor Dependency Example
This example shows how to configure a requiredFor inter-field dependency that makes the City field editable only when the Country field has a value. This dependency is configured by implementing JSON in the Inter-Field Dependencies field of the Country field record.
{
"requiredFor":{
"dev_city":{
"direction":"target",
"relationship":"dev_city_country"
}
}
}
dependsOn One-Way Dependency Example
This example shows how to use dependsOn to configure a one-way inter-field dependency that makes the City field editable only when the Country field has a value, and makes the City field selectable only if the Country field value matches that of the Country field in the City field record. This dependency is configured by implementing JSON in the Inter-Field Dependencies field of the City field record.
| Before you implement the following code, be sure to clear the InterField Dependencies field in the Country object. |
{
"dependsOn":{
"dev_country":{
"direction":"source",
"relationship":"dev_city_country"
}
}
}
dependsOn Two-Way Dependency Example
This example shows how to configure a two-way dependency between two editable fields, Country and City.
When the Country field has no configured value, all City fields are selectable. When a field value is configured for the Country field, it is selectable only if the value matches the Country field value in the City field record. The same is true for a City field, which is selectable only if the value matches the City field value in the Country field record. When the Country field value is cleared, the related City field value is automatically cleared also. The first part of this two-way dependency is configured by implementing JSON in the Inter-Field Dependencies field of the Country field record.
{
"dependsOn":{
"dev_city":{
"bidirectional":true,
"direction":"target",
"relationship":"dev_city_country"
}
}
}
The second part of this two-way dependency is configured by implementing JSON in the Inter-Field Dependencies field of the City field record.
{
"dependsOn": {
"dev_country": {
"bidirectional": true,
"cascade": true,
"direction": "source",
"relationship": "dev_city_country"
}
}
}
For more information: