CRM has some built in rules that stop you from deleting Companies that have outstanding actions against them.


Below is a complete summary of those rules.

You can delete a company if it has:

No Communications with status = 'Pending'

No Oppos with status 'In Progress' or 'Won'

No Quotes with status 'Active'

No Orders with status 'Active'

No Cases with status 'In Progress'

More information: 

Here is the SQL used to check this by CRM (for Company ID 1227):

SELECT * FROM vListCommunication  WITH (NOLOCK)  WHERE Comp_CompanyId=1227 AND  Comm_Status = N'Pending' AND Comm_Type <> N'RecuMaster'
SELECT * FROM vListOpportunity  WITH (NOLOCK)  WHERE Oppo_PrimaryCompanyId=1227 AND ( Oppo_Status = N'In Progress' OR  Oppo_Status = N'Won')
SELECT * FROM vListQuotes  WITH (NOLOCK)  WHERE QUOT_DELETED IS NULL AND Oppo_PrimaryCompanyId=1227 AND  Quot_Status = N'Active'
SELECT * FROM vListOrders  WITH (NOLOCK)  WHERE ORDE_DELETED IS NULL AND Oppo_PrimaryCompanyId =1227 AND  orde_Status = N'Active'
SELECT * FROM vListCases  WITH (NOLOCK)  WHERE Case_PrimaryCompanyId=1227 AND  Case_Status = N'In Progress'