<turbo-stream action="update" target="wiki_card"><template>

<h1>Error 0x80040265: Cannot Delete Due to References</h1>
<div class="trix-content"><p><strong>Error Message</strong>: "The object cannot be deleted because it is referenced by one or more other objects".<br><strong>What it means</strong>: Dynamics 365 prevents deletion because other records depend on this one. You must remove or reassign dependent records first.</p><p><strong>Common Scenarios<br></strong><strong></strong></p><figure class="attachment attachment--content"><table class="table table-bordered"><thead><tr><td>Scenario</td><td>Example</td><td>Cause</td><td>Solution</td></tr></thead><tbody><tr><td>Account with Contacts</td><td>Cannot delete Account 'Contoso' because it has 15 related Contacts</td><td>Contacts reference the Account via Parent Customer field</td><td>Delete or reassign Contacts first</td></tr><tr><td>Product in Price List</td><td>Cannot delete Product because it exists in ProductPriceLevel records</td><td>ProductPriceLevel references Product</td><td>Remove from price lists first</td></tr><tr><td>Currency in Transactions</td><td>Cannot delete EUR currency because Quotes use it</td><td>Quotes, Orders, Invoices reference the Currency</td><td>Deactivate instead of delete</td></tr><tr><td>Quote with Orders</td><td>Cannot delete Quote because Orders were created from it</td><td>Orders reference originating Quote</td><td>Delete Orders first or close Quote</td></tr><tr><td>Custom Entity Cascade</td><td>Cannot delete custom parent record with related child records</td><td>Relationship configured as Restrict delete</td><td>Delete children or change cascade rules</td></tr></tbody></table><figcaption class="attachment__caption"></figcaption></figure><strong><br>How to Fix</strong><p></p><p><strong>Step 1: Identify What's Blocking the Delete</strong></p><p>The error message usually includes which entity type is referencing the record. If not clear:</p><ul><li>Open the record in D365 UI: Look for related records in sub-grids</li><li>Check entity relationships: Settings &gt; Customizations &gt; Entities &gt; Relationships</li><li>Query related records: Use Advanced Find or API to find dependencies</li></ul><p><strong>Step 2: Choose Your Strategy</strong></p><p><strong><u>Option A: Delete Dependent Records First (Cascade Delete)</u></strong></p><p>Best for: Test data, bulk cleanup, parent-child hierarchies</p><ul><li>Query all related records</li><li>Delete child records first</li><li>Then delete parent record</li></ul><p><strong><u>Option B: Reassign References (Preserve Data)</u></strong></p><p>Best for: Production data, maintaining history</p><ul><li>Find all dependent records</li><li>Update them to reference a different parent</li><li>Then delete original record</li></ul><p><strong><u>Option C: Deactivate Instead of Delete</u></strong></p><p>Best for: Master data (Currencies, Products, Price Lists)</p><ul><li>Set State to Inactive instead of deleting</li><li>Preserves historical references</li><li>Prevents use in new transactions</li></ul><p><strong><u>Option D: Remove References (Clear Lookups)</u></strong></p><p>Best for: Optional lookup fields</p><ul><li>Set lookup field to null on dependent records</li><li>Then delete the record</li></ul></div>
</template></turbo-stream>

