We recently ran into a client issue that I have just reported to Swiftpage as a bug (Ticket 8010151686)
This applies to all Saleslogix web clients, including version 8.1.
When you win an opportunity the opportunity products get copied to assets with ACCOUNTPRODUCT.OPPORTUNITYID and ACCOUNTPRODUCT.OPPPRODUCTID populated based on the source records.
If you later delete that opportunity the corresponding assets keep the values in these two fields even though those IDs are no longer valid.
When attempting to close (win) another opportunity at the account that now has these bad asset records you receive an error on the close opportunity dialog due to the NHibernate AccountProduct.Opportunity mapping being invalid.
Steps to reproduce:
- Create an opportunity for any account with one product.
- Close win the opportunity.
- Verify the Asset now exists.
- Delete the Opportunity.
- Create a new opportunity for the same account with at least one product.
- Close win the second opportunity. On the close dialog you will get an error and are then unable to win any further opps for this account until the bad IDs are removed from the ACCOUNTPRODUCT table
You can fix this by running a SQL statement of **boilerplate warning: do this in a test system first**:
update sysdba.accountproduct set opportunityid=null where opportunityid not in (select OPPORTUNITYID from sysdba.opportunity)
sysdba.accountproduct set oppproductid=null where oppproductid not in
(select oppproductid from sysdba.opportunity_product)
Even better would be a custom Post Execute Step OnBeforeDelete entity event at the Opportunity. Something like this should work **boilerplate warning: written for this blog and not tested**:
if(opportunity!=null && opportunity.Account !=null)
foreach(Sage.Entity.Interfaces.IAccountProduct ap in opportunity.Account.AccountProducts)
if(ap.Opportunity == opportuinity)
ap.Opportunity = null;
ap.OppProductId = null;
You would also need a custom OnBeforeDelete entity event at the OpportunityProduct. Something like this should work **boilerplate warning: written for this blog and not tested**:
if(opportunityproduct!=null && opportunityproduct.Opportunity!=null && opportunityproduct.Opportunity.Account !=null)
foreach(Sage.Entity.Interfaces.IAccountProduct ap in opportunityproduct.Opportunity.Account.AccountProducts)
if(ap.OppProductId == opportunityproduct.Id.ToString())
ap.OppProductId = null;