This is an excellent use case that demonstrates best practices for dynamic forms with conditional fields in Pega Forms Management. Let me provide a comprehensive implementation guide based on Rachel’s success story and add technical details for others looking to implement similar solutions.
Implementation Architecture:
1. Dynamic UI Controls - Section Structure:
The form is organized into a master section with embedded conditional sections:
MasterOnboardingSection
├── CustomerTypeSelection (always visible)
├── CommonFieldsSection (always visible)
├── BusinessCustomerSection (conditional)
└── IndividualCustomerSection (conditional)
Each conditional section has a When rule attached to its visibility property that evaluates based on the .CustomerType property value.
2. When Rule Strategy for Conditional Visibility:
Create reusable When rules:
IsBusinessCustomer: `.CustomerType = “Business”
IsIndividualCustomer: `.CustomerType = “Individual”
IsInternationalBusiness: `.CustomerType = “Business” AND .Country != “USA”
These When rules are referenced in:
- Section visibility properties
- Field visibility properties
- Validation rule preconditions
- Required field logic
Best practice: Use the same When rule across multiple UI elements to ensure consistent behavior and easier maintenance. Changes to visibility logic only need to be made in one place.
3. Conditional Visibility Implementation:
For each conditional section:
- Open the section rule in Designer Studio
- Navigate to the section’s properties
- Set “Visible” property to “Condition (when rule)”
- Reference the appropriate When rule (e.g., IsBusinessCustomer)
- Set “Refresh” behavior to “Refresh on property change” and specify `.CustomerType
This ensures the form dynamically updates when the user changes the customer type selection without requiring a page refresh or submit action.
4. Validation Rules with Conditional Logic:
Each field group has validation rules that only execute when the fields are visible:
// Business Tax ID Validation
// Precondition: IsBusinessCustomer = true
// Validation logic:
IF .BusinessTaxID matches pattern
THEN valid
ELSE error "Invalid format"
Key implementation points:
- Attach validation rules to the property definitions
- Set preconditions that match visibility When rules
- Use “Edit Validate” rules for complex validation logic
- Display validation errors inline near the relevant fields
5. Dynamic Required Fields:
Implement conditional required field logic:
- In field properties, set “Required” to “Condition (when rule)”
- Reference the same When rule used for visibility
- This ensures fields are only required when they’re visible
- Prevents validation errors on hidden fields during submission
Example: Business Tax ID field is required when IsBusinessCustomer = true, but not required (and not validated) when the user selects Individual customer type.
6. User Experience - Real-time Form Updates:
To answer the question about user experience during customer type switching:
Configure the CustomerType dropdown with refresh-on-change behavior:
- Set the dropdown action to “Refresh-Section” or “Refresh-Other”
- Specify the master section as the refresh target
- This triggers immediate re-evaluation of all When rules
- Conditional sections appear/disappear instantly without page reload
- Previously entered data in hidden sections is preserved (not cleared)
Users see a smooth transition where irrelevant fields fade out and relevant fields fade in, creating an intuitive, responsive experience.
7. Data Persistence Strategy:
When fields become hidden, their data is preserved on the clipboard but not validated or required:
- If a user enters business data, switches to individual, then switches back to business, their original business data is still there
- This prevents data loss from accidental customer type changes
- Only visible fields are validated during submission
- Hidden field data can be cleared via data transform if needed for data hygiene
8. Performance Optimization:
For forms with many conditional fields:
- Use lazy loading for complex conditional sections
- Implement section visibility caching to avoid repeated When rule evaluation
- Minimize the number of refresh targets - refresh only the container section, not individual fields
- Use client-side When rules when possible (evaluated in browser, not server)
9. Testing Strategy:
Comprehensive testing approach:
- Test all customer type combinations and transitions
- Verify validation rules fire only for visible fields
- Test required field logic across all scenarios
- Verify data persistence when switching between customer types
- Test form submission with various field combinations
- Validate that hidden fields don’t cause submission failures
10. Results and Metrics:
Based on Rachel’s implementation, key success metrics:
- Onboarding completion rate: 67% → 94% (27% improvement)
- Average completion time: 12 minutes → 7 minutes (42% reduction)
- Data entry error rate: 23% → 8% (65% reduction)
- User satisfaction: Significantly improved due to cleaner, more relevant forms
- Support tickets: Reduced by 55% as users have fewer questions about irrelevant fields
Implementation Timeline:
- Week 1: Design form structure and identify conditional field groups
- Week 2: Create When rules and configure section visibility
- Week 3: Implement validation rules and required field logic
- Week 4: Testing and refinement
- Week 5: User acceptance testing and deployment
Best Practices Summary:
- Create reusable When rules for common visibility conditions
- Mirror visibility logic in validation rule preconditions
- Use refresh-on-change for the controlling property (CustomerType)
- Preserve data in hidden fields to prevent accidental data loss
- Test all transition scenarios thoroughly
- Monitor form completion rates and error rates post-deployment
- Continuously refine based on user feedback and analytics
Lessons Learned:
- Start with the most common customer type as the default view
- Provide clear visual feedback during field transitions
- Don’t overuse conditional visibility - too many dynamic changes can confuse users
- Balance between dynamic forms and form complexity - sometimes separate forms for different customer types are clearer
- Invest time in proper When rule design upfront - changes are easier with well-structured rules
This dynamic forms approach with conditional fields and validation rules is applicable to many use cases beyond customer onboarding: loan applications, product configuration, service requests, employee onboarding, and any process where form requirements vary based on user selections. The key is identifying the controlling properties (like CustomerType) and systematically applying conditional visibility and validation logic throughout the form structure.