Unable to Win Opportunities for Some Records in the Saleslogix web client

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:

  1. Create an opportunity for any account with one product.
  2. Close win the opportunity.
  3. Verify the Asset now exists.
  4. Delete the Opportunity.
  5. Create a new opportunity for the same account with at least one product.
  6. 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)

update
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;
                        ap.Save();
                    }
                }
            }

 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;
                        ap.Save();
                    }
                }
            }

          

 

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!