Skip to Content
Docs@PortalDependency — conditional rules

@PortalDependency — conditional rules

Field-level annotation (repeatable) — defines conditional rules controlling field visibility, available options, and numeric range based on other form field values.

@Target(AnnotationTarget.FIELD, AnnotationTarget.FUNCTION) @Retention(AnnotationRetention.RUNTIME) @Repeatable annotation class PortalDependency( val field: String = "", val operator: DependencyOperator = DependencyOperator.UNSPECIFIED, val value: String = "", val values: Array<String> = [], val condition: String = "", val visibility: DependencyVisibility = DependencyVisibility.NONE, val allowedValues: Array<String> = [], val min: String = "", val max: String = "", val message: String = "", val clearOnHide: Boolean = true )

Parameters

ParameterTypeDefaultDescription
fieldString""Name of the field this rule depends on
operatorDependencyOperatorUNSPECIFIEDComparison operator
valueString""Value to compare (single)
valuesArray<String>[]Value set for IN / NOT_IN
conditionString""Complex condition as JSON AST (allOf/anyOf/not)
visibilityDependencyVisibilityNONESHOW, HIDE, or NONE
allowedValuesArray<String>[]Restricts SELECT options to this list
minString""Min numeric value; a number ("10") or field ref ("$creditLimit")
maxString""Max numeric value; a number or field ref
messageString""Message shown when the rule is active
clearOnHideBooleantrueWhether to clear field value when it becomes hidden

DependencyVisibility

ValueDescription
NONERule does not affect visibility — only restricts values or range
SHOWField is visible only when condition is met
HIDEField is hidden when condition is met

DependencyOperator

ValueDescription
UNSPECIFIEDNo operator — use when condition is a JSON string in condition
EQEquality
NEQInequality
INValue in set
NOT_INValue not in set
CONTAINSContains substring
NOT_CONTAINSDoes not contain substring
IS_EMPTYValue is empty
IS_NOT_EMPTYValue is not empty
GT / GTE / LT / LTENumeric comparisons

Examples

Conditional visibility (SHOW):

@Column @PortalField(label = "VIP Discount (%)", order = 5, renderer = RendererType.DECIMAL) @PortalDependency( field = "customerType", operator = DependencyOperator.EQ, value = "VIP", visibility = DependencyVisibility.SHOW, message = "VIP discount available only for VIP customers" ) var vipDiscount: Double = 0.0

Conditional visibility (HIDE):

@Column @PortalField(label = "Cancellation Reason", order = 8, renderer = RendererType.TEXTAREA) @PortalDependency( field = "status", operator = DependencyOperator.NEQ, value = "CANCELLED", visibility = DependencyVisibility.HIDE ) var cancellationReason: String = ""

Restricting available options:

@Column @PortalField(label = "Tags", order = 4, renderer = RendererType.MULTI_SELECT, selectEnum = Tag::class) @PortalDependency( field = "customerType", operator = DependencyOperator.EQ, value = "New", allowedValues = ["NEW"], message = "New customers can only have the NEW tag" ) @PortalDependency( field = "customerType", operator = DependencyOperator.EQ, value = "Premium", allowedValues = ["PREMIUM", "REGULAR", "NEW"] ) var tags: String = ""

Numeric range constraint:

@Column @PortalField(label = "Credit Limit", order = 3, renderer = RendererType.DECIMAL) @PortalDependency( field = "customerType", operator = DependencyOperator.EQ, value = "New", max = "5000", message = "New customer — max 5000" ) @PortalDependency( field = "customerType", operator = DependencyOperator.EQ, value = "VIP", min = "5000", max = "500000" ) var creditLimit: Double = 0.0

Field reference in range ($ prefix):

@Column @PortalField(label = "Sale Price", order = 5, renderer = RendererType.DECIMAL) @PortalDependency( field = "isDiscounted", operator = DependencyOperator.EQ, value = "true", max = "\$listPrice" // max = value of the listPrice field ) var salePrice: Double = 0.0

Complex JSON condition (anyOf/allOf):

@Column @PortalField(label = "Special Field", order = 9, renderer = RendererType.TEXT) @PortalDependency( condition = """ { "anyOf": [ {"field": "customerType", "operator": "eq", "value": "VIP"}, { "allOf": [ {"field": "isActive", "operator": "eq", "value": "true"}, {"field": "loyaltyPoints", "operator": "gte", "value": "1000"} ] } ] } """, visibility = DependencyVisibility.SHOW ) var specialField: String = ""

IN operator (multiple values):

@Column @PortalField(label = "Priority Service", order = 10, renderer = RendererType.BOOLEAN) @PortalDependency( field = "customerType", operator = DependencyOperator.IN, values = ["VIP", "PREMIUM", "BUSINESS"], visibility = DependencyVisibility.SHOW ) var priorityService: Boolean = false
Last updated on