The comprehensive solution requires addressing all three focus areas:
1. Conditional Validation Logic - Structured Approach:
The issue is that Power Apps doesn’t reliably track dependencies in complex nested formulas. You need to restructure your validation logic using intermediate variables and explicit change tracking.
First, create context variables that update whenever dependent fields change. In the OnChange event of EmploymentType dropdown:
UpdateContext({
IsFullTime: EmploymentType.Selected.Value = "Full-Time",
IsContractor: EmploymentType.Selected.Value = "Contractor"
});
If(IsContractor, UpdateContext({ShowContractFields: true}))
In the OnChange event of Department dropdown:
UpdateContext({
IsSales: Department.Selected.Value = "Sales",
IsIT: Department.Selected.Value = "IT"
})
Now create a validation variable that combines these conditions. In the OnVisible event of your form:
UpdateContext({
ValidationRules: {
SalesRegion: IsFullTime && IsSales,
TechSkills: IsIT,
ContractEndDate: IsContractor
}
})
2. Nested Rule Handling - Reliable Evaluation:
Instead of setting the Required property directly (which Power Apps doesn’t re-evaluate consistently), implement a comprehensive validation function.
Create a validation collection that tracks all rules. In the OnChange of ANY field that affects validation:
ClearCollect(ValidationErrors,
If(ValidationRules.SalesRegion && IsBlank(SalesRegion.Text),
{Field: "SalesRegion", Message: "Required for full-time sales"}),
If(ValidationRules.TechSkills && IsBlank(TechSkills.Text),
{Field: "TechSkills", Message: "Required for IT department"}),
If(ValidationRules.ContractEndDate && IsBlank(ContractEndDate.SelectedDate),
{Field: "ContractEndDate", Message: "Required for contractors"})
)
Display validation errors in real-time using a gallery or labels:
- Add a label below each field showing its validation error
- Set the label’s Text property to: `LookUp(ValidationErrors, Field = “SalesRegion”).Message
- Set Visible property to: `!IsBlank(LookUp(ValidationErrors, Field = “SalesRegion”).Message)
Implement submit button validation:
If(CountRows(ValidationErrors) = 0,
SubmitForm(EmployeeForm),
Notify("Please correct validation errors", NotificationType.Error)
)
3. Onboarding Workflow Impact - Data Quality Assurance:
To ensure complete employee records are created:
a) Add server-side validation as backup:
- Create Dataverse business rules for critical validations
- These execute even if client-side validation is bypassed
- Navigate to Employee table → Business Rules → New Rule
- Configure conditions: If Employment Type = Full-Time AND Department = Sales, then Sales Region is required
b) Implement progressive form validation:
- Break the onboarding form into multiple screens/steps
- Validate each section before allowing progression to next step
- This prevents users from reaching submit with incomplete data
- Use a collection to track completed sections
c) Add pre-submission validation summary:
- Before form submission, show a summary screen
- Display all entered values with section headers
- Highlight any fields that failed validation
- Require explicit confirmation before final submit
d) Implement workflow-level validation:
- In your Power Automate onboarding workflow, add a condition after form submission
- Check if required fields are populated based on employment type and department
- If validation fails, send the form back to submitter with specific error details
- Log validation failures to a tracking table for reporting
e) Create validation monitoring:
- Build a Power BI report showing validation failure rates by field
- Track which nested conditions fail most frequently
- Identify if certain field combinations are problematic
- Use this data to refine your validation logic
Complete Implementation Example:
In your form’s OnVisible property:
// Initialize validation tracking
ClearCollect(ValidationState, {Initialized: true});
UpdateContext({FormMode: "Edit"})
In EmploymentType.OnChange:
UpdateContext({EmploymentTypeValue: EmploymentType.Selected.Value});
Set(ValidationTrigger, !ValidationTrigger)
In Department.OnChange:
UpdateContext({DepartmentValue: Department.Selected.Value});
Set(ValidationTrigger, !ValidationTrigger)
Create a hidden label that runs validation whenever ValidationTrigger changes:
Text property of hidden label:
ClearCollect(ActiveValidations,
{Rule: "SalesRegion",
Required: EmploymentTypeValue="Full-Time" && DepartmentValue="Sales",
Value: SalesRegion.Text},
{Rule: "TechSkills",
Required: DepartmentValue="IT",
Value: TechSkills.Text}
);
Filter(ActiveValidations, Required && IsBlank(Value))
Submit button OnSelect:
If(CountRows(Filter(ActiveValidations, Required && IsBlank(Value))) = 0,
SubmitForm(EmployeeForm);
Navigate(ConfirmationScreen),
Notify("Complete all required fields", NotificationType.Error)
)
This approach ensures:
- All nested conditions are evaluated reliably
- Validation updates in real-time as users change fields
- Submit button prevents incomplete submissions
- Server-side business rules catch any bypassed client validation
- Onboarding workflow receives complete, validated employee records
The key is using intermediate variables that explicitly track field states and triggering re-validation whenever any dependent field changes. This overcomes Power Apps’ limitations with complex nested formulas.