Solved

Cannot delete a customer - referenced in another record

  • 5 October 2022
  • 5 replies
  • 166 views

Userlevel 6
Badge +3

I’m doing testing on a custom application in 2021R2.  I am trying to delete a customer from the sample database and I am getting this message:

I’ve run a sql query against every table that has a field name with ‘%BAccountID%’ and ‘%CustomerID%’ (which was over a hundred).  The only place that account ID is referenced is in the Customer, BAccount, Location and a couple other customer setup tables.  I can find no records in anything related to Equipment.

I’ve tried debugging the Delete process but I cannot find the place in the available code repository where validations are done to check for orphan records, so….does anyone recognize “Equipment” and have any idea what that table might be? 

icon

Best answer by Django 5 October 2022, 16:41

View original

5 replies

Userlevel 7
Badge +5

FSEquipment is probably what you’re looking for.

And looking in FSEquipment.cs I see:

public static class FK
{
...
public class Customer : AR.Customer.PK.ForeignKeyOf<FSEquipment>.By<customerID> { }
...
}

 

Userlevel 5
Badge +1

you should look for CustomerID too, that being said Equipment Record in the error indicates FSEquipment table

Userlevel 6
Badge +3

 If I do a select on that table for the customerID 4899 which is Ace Bartender, it comes up with no records.  I even checked that there weren’t any CustomerLocationID’s for Ace in that table (checking for all the LocationID records for Ace).

Just to make sure I wasn’t chasing a ghost, I just truncated the FSEquipment table and I was able to delete the customer record.

I’m going restore the DB and try to find out some relationship the FSEquipment table has that is causing the issue.  If there are no customerid records for that customer in that table, maybe it is something linked to the FSEquipment table.

Userlevel 6
Badge +3

I found the records in the FSEquipment table causing the issue.  The value in the error message is actually the RefNbr field.  

There is probably some FK value in those records causing the issue even though the customerId and customerlocationId fields are not Ace Bartender.

You’ve probably figured out what I am doing here by now.  I’m trying to change the customer account to a different customer account.  I know this is not supported by Acumatica, but my customer is begging for this, so please withhold your chastisements.  I’m just seeing what I can do in my testing environment.  If I am not comfortable with my solution, don’t worry.  I won’t use the application and corrupt the database.

Thanks all for you inputs.  Just for kicks, in 10 hours or so, after I finally figure it out, I’ll post an update.

 

Userlevel 6
Badge +3

I found it.  The OwnerID field is a customerid based field.  That was the problem.

Thanks all for jumping in so quickly.  

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved