User Acceptance Testing fails in forms management due to Dataverse relationship errors

We’re experiencing critical UAT failures in our Power Apps forms that reference Dataverse relationships. Our test cases consistently fail when forms try to validate lookup fields against related tables.

The main issue involves referential integrity checks failing during form submission. When users select values from lookup fields, the form throws validation errors even though the referenced records exist in Dataverse. We’ve verified that test data masking is properly configured, but the lookup field validation still blocks form submissions.

Here’s the error pattern we’re seeing:


Lookup validation failed: Related record not found
Table: Accounts, Field: PrimaryContact
Referenced Table: Contacts, ID: {guid}

This is blocking our entire UAT cycle and we need to deploy to production next week. Has anyone dealt with Dataverse referential integrity issues during testing phases? What’s the proper approach to configure lookup field validation for test environments?

I’ve seen this before. The issue is usually with how Dataverse handles lookup relationships when test data is copied or masked. Check if your test environment has the same security roles and column-level security settings as production. Lookup validation can fail if the test user doesn’t have read access to the referenced table, even if the record exists.

Thanks for the quick response. I verified security roles and all test users have System Administrator privileges in the test environment. The referenced Contact records definitely exist and are visible in the Dataverse table. The lookup field shows the options correctly in the dropdown, but validation fails on submit. Could this be related to how we’re masking data during environment refresh?

Let me provide a comprehensive solution addressing all three aspects of your issue:

Dataverse Referential Integrity: The core problem is that your test data masking process is breaking the GUID relationships between tables. When you mask the Contact table, the Account.PrimaryContact lookup still references the old GUIDs. You need a relationship-aware masking approach.

Test Data Masking Strategy: Implement cascading GUID mapping during your masking process:


// Pseudocode - Relationship-aware masking steps:
1. Export parent table (Contacts) with original GUIDs to mapping table
2. Apply masking to Contact records and capture old_GUID -> new_GUID mappings
3. Update all child tables (Accounts, Cases, etc.) lookup fields using GUID mapping
4. Validate relationship integrity with Dataverse API queries
5. Run referential integrity check across all masked tables
// Reference: Power Platform Admin Center - Data Management Guide

Alternatively, use the Power Platform CLI to create synthetic test data that maintains proper relationships from inception:


pac data create --entity contact --file test_contacts.json
pac data create --entity account --file test_accounts.json --mapping contacts

Lookup Field Validation: Ensure your forms handle lookup validation correctly by:

  1. Verify Relationship Behavior Settings: In Power Apps form designer, check each lookup field’s relationship behavior. Set to ‘Referential’ not ‘Referential, Restrict Delete’ during UAT to avoid cascading validation failures.

  2. Update Form Validation Logic: If you have custom OnSave handlers, ensure they query Dataverse with proper error handling:


if (lookupValue != null) {
  // Verify referenced record exists
  Xrm.WebApi.retrieveRecord(entityName, lookupId)
}
  1. Connection References: Check your environment’s connection references in the solution. UAT environment connections might be pointing to production Dataverse, causing validation against wrong data set.

  2. Clear Form Cache: After fixing GUID mappings, clear the Power Apps form cache. Users need to reload forms to get updated lookup metadata.

Immediate Fix for Your UAT Blocker: Run this diagnostic in your test environment:

  • Export your failing test case’s Account record
  • Check the PrimaryContact GUID value
  • Query Contacts table for that specific GUID
  • If not found, you’ve confirmed broken relationships
  • Re-run your environment copy with ‘Everything’ option to reset
  • Apply masking AFTER verifying all lookups resolve correctly

This approach ensures referential integrity throughout your test data lifecycle while maintaining proper data privacy through masking. Your UAT should proceed once GUID relationships are preserved during the masking process.

Data masking can definitely cause this. When you mask data in Dataverse, if you’re changing GUIDs or primary keys, the lookup relationships break. The lookup field might display cached values but the actual relationship validation fails because the GUID no longer matches. You need to ensure your masking strategy preserves relationship integrity. Use referential masking where child records update their lookup GUIDs when parent records are masked. Also check if you’re using alternate keys - those need special handling during masking.

For UAT environments, I recommend using Dataverse’s built-in data seeding rather than copying and masking production data. Create synthetic test data that maintains proper relationships from the start. If you must mask production data, use the Power Platform Admin Center’s copy environment feature with the ‘Everything’ option, then apply masking scripts that update lookup GUIDs in a cascading manner. Start with parent tables, mask them, capture the GUID mappings, then update child table lookups using those mappings. This preserves referential integrity throughout the masking process.

I want to add that you should also check your form’s OnSave event handlers. Custom JavaScript validation can interfere with Dataverse’s native lookup validation.