Data Set Attributes Rules
Overview
Attribute rules are used to define under which condition a field shall become mandatory, visible and/or read-only. For each field specific rules can be defined on different data set entities. At runtime rules will be automatically executed to adapt the display of the field within the page.
Data Set Attributes Rules interface for configuring field behavior conditions
Rule Types
Visibility Rule
- Purpose: Control when a field is visible to users
- Expression: Boolean expression that evaluates to true/false
- Behavior: Field appears only when the rule evaluates to true
- Use Cases: Show fields based on user selections or data conditions
Mandatory Rule
- Purpose: Control when a field becomes required
- Expression: Boolean expression that evaluates to true/false
- Behavior: Field becomes required when the rule evaluates to true
- Use Cases: Make fields mandatory based on other field values or conditions
Read-only Rule
- Purpose: Control when a field cannot be edited
- Expression: Boolean expression that evaluates to true/false
- Behavior: Field becomes read-only when the rule evaluates to true
- Use Cases: Prevent editing based on status, permissions, or data conditions
Rule Configuration
Attribute Name
- Purpose: Name of the attribute for which the rules apply
- Selection: Choose from available attributes in the data set entity
- Scope: Rules apply only to this specific attribute
Rule Syntax
The rules syntax is based on the Opadeez Scripting Language and supports:
- Boolean Expressions: true/false, comparisons, logical operators
- Field References: Access values from other fields in the data set
- Operators: =, <>, <, >, <=, >=, AND, OR, NOT
- Functions: Built-in scripting functions for complex logic
Scripting Reference: For complete syntax documentation, operators, functions, and examples, see the Opadeez Scripting Language Reference.
Dynamic Rule Behavior
Important: When a rule is dynamic (uses values of other fields that can be modified on screen), it is necessary to put on the screen all the fields used in the condition, in order for the condition to be dynamically updated on the screen.
Dynamic Updates
For example, if Field "A" has a visibility rule stating "B <> 0 AND C <> 0", it is necessary to have both fields B and C on the screen to allow A to become dynamically visible or hidden when the value of B and C changes. Otherwise, the visibility rule will be refreshed only when the page is refreshed.
Field Dependencies
- Screen Presence: All referenced fields must be present on the same screen
- Real-time Updates: Rules evaluate immediately when dependent field values change
- Page Refresh: Rules without screen dependencies only update on page refresh
Practical Examples
Conditional Visibility
- Rule:
CustomerType = "Premium" - Effect: Field only visible for premium customers
- Use Case: Show special pricing fields for premium customers only
Conditional Mandatory
- Rule:
OrderAmount > 1000 - Effect: Field becomes required for high-value orders
- Use Case: Require approval signature for large orders
Conditional Read-only
- Rule:
Status = "Approved" - Effect: Field cannot be edited once approved
- Use Case: Prevent changes to approved documents
Complex Conditions
- Rule:
UserRole = "Manager" AND Department = "Sales" - Effect: Field visible only to sales managers
- Use Case: Role-based field visibility
Best Practices
Rule Design
- Simple Logic: Keep rules as simple as possible for maintainability
- Clear Conditions: Use descriptive field names and logical operators
- Test Thoroughly: Verify rules work correctly with various data combinations
- Document Rules: Comment complex rules for future maintenance
Performance Considerations
- Field Dependencies: Minimize the number of fields referenced in rules
- Screen Layout: Include all dependent fields on the same screen for dynamic updates
- Rule Complexity: Avoid overly complex expressions that impact performance
- Testing: Test rules with realistic data volumes
User Experience
- Logical Flow: Ensure rule behavior makes sense to users
- Clear Feedback: Provide clear indication when fields become mandatory
- Consistent Behavior: Apply similar rules consistently across the application
- Error Handling: Handle cases where rules cannot be evaluated
Common Use Cases
Progressive Disclosure
- Scenario: Show additional fields based on user selections
- Implementation: Use visibility rules to reveal relevant fields
- Benefit: Simplified user interface with contextual information
Data Validation
- Scenario: Make fields mandatory based on business rules
- Implementation: Use mandatory rules with conditional logic
- Benefit: Ensure data completeness for specific scenarios
Workflow Control
- Scenario: Prevent editing at certain workflow stages
- Implementation: Use read-only rules based on status fields
- Benefit: Maintain data integrity throughout process lifecycle
Role-Based Access
- Scenario: Show different fields to different user roles
- Implementation: Use visibility rules with user role conditions
- Benefit: Customized interface based on user permissions
Troubleshooting
Rules Not Working
- Check Syntax: Verify rule expressions use correct scripting syntax
- Field References: Ensure referenced fields exist and are spelled correctly
- Screen Dependencies: Confirm all referenced fields are on the same screen
- Data Types: Verify comparisons use appropriate data types
Performance Issues
- Complex Rules: Simplify overly complex rule expressions
- Field Count: Reduce the number of fields referenced in rules
- Rule Count: Minimize the total number of rules per screen
- Testing: Test with realistic data volumes and user scenarios
Related Topics
- Data Set Definition: Understanding data set structure and entities
- Entities & Attributes: Creating the fields that rules apply to
- Opadeez Scripting Language: Complete reference for writing attribute rules
- Scripts: Creating standalone script actions
- Pages Designer: Creating screens that display fields with rules
Pro Tip: Start with simple visibility rules to show/hide sections of forms, then gradually add mandatory and read-only rules as needed. Always test rules with real user scenarios to ensure they behave as expected.