Skip to main content
Answer

Cannot delete a customer - referenced in another record

  • October 5, 2022
  • 5 replies
  • 386 views

Joe Schmucker
Captain II
Forum|alt.badge.img+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? 

Best answer by Django

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> { }
...
}

 

5 replies

Forum|alt.badge.img+7
  • Captain II
  • Answer
  • October 5, 2022

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> { }
...
}

 


Shawn Burt
Jr Varsity I
Forum|alt.badge.img+1
  • Jr Varsity I
  • October 5, 2022

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


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • October 5, 2022

 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.


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • October 5, 2022

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.

 


Joe Schmucker
Captain II
Forum|alt.badge.img+3
  • Author
  • Captain II
  • October 5, 2022

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

Thanks all for jumping in so quickly.