Dynamic field validation fails in forms management with conditional rules for employee onboarding

Our employee onboarding workflow uses a Power Apps form with complex conditional field validation rules, but the validation is failing for nested conditions. The form collects employee information with fields that become required based on previous selections.

For example, if EmploymentType = “Contractor”, then ContractEndDate becomes required. If Department = “IT”, then TechSkills becomes required. These individual rules work fine. However, when we have nested conditions like “If EmploymentType = ‘Full-Time’ AND Department = ‘Sales’, then SalesRegion is required”, the validation doesn’t fire correctly.


If(EmploymentType.Selected.Value = "Full-Time" &&
   Department.Selected.Value = "Sales",
   SalesRegion.Required = true,
   SalesRegion.Required = false)

The form allows submission even when SalesRegion is empty for full-time sales employees. Simple single-condition validations work, but nested AND/OR logic fails inconsistently. This breaks our onboarding workflow because incomplete employee records get created in the system. Has anyone successfully implemented nested conditional validation rules in Power Apps forms?

The issue is likely with how you’re setting the Required property dynamically. Power Apps sometimes doesn’t re-evaluate the Required property when dependent fields change. Instead of setting Required directly, use a validation rule with the OnSelect of your submit button. Check all conditions there and show an error message if validation fails, preventing form submission.

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.

That’s a good suggestion. I tried adding validation in the submit button’s OnSelect, but I’m still seeing inconsistent behavior. Sometimes the validation fires, sometimes it doesn’t. Could this be related to the order in which the form evaluates the conditions? Like if Department changes after EmploymentType, does the nested condition re-evaluate?

I’ve found that using Power Apps business rules instead of formulas works better for complex conditional validation. Business rules are server-side and more reliable for nested conditions. Create a business rule in Dataverse that evaluates the conditions and sets field requirements. The downside is business rules execute on save, not in real-time, so users only see validation errors after clicking submit. But it’s more consistent than client-side formulas for nested logic.