If you have ever ran into a popup error in the SalesLogix web client, trying to save an Opportunity that has its status set to “Closed – Won” that looks like:
Object reference not set to an instance of an object.
The issue is likely due to data issues that are causing the standard Sage business rule MoveOppProductsToAssets to fail. This rule is invoked on the Opportunity entity’s OnBeforeUpdate event. The actual code within this business rule is compiled in the Sage.SalesLogix.BusinessRules.dll assembly so it can not be modified, but here is a screen shot of the code:
As you can see there are two assumptions made within this code:
- Each Asset at the Opportunity’s Account must have a product. Meaning a valid PRODUCTID in ACCOUNTPRODUCT.PRODUCTID
- Each Opportunity product must have a valid product
If either of these conditions is not met then you will receive the error.
These queries should find any records where this is going to be a problem:
select * from ACCOUNTPRODUCT where PRODUCTID is null or PRODUCTID not in (select PRODUCTID from PRODUCT)
select * from OPPORTUNITY_PRODUCT where PRODUCTID is null or PRODUCTID not in (select PRODUCTID from PRODUCT)
Fixing the data problems is a little more complicated because you must either update the rows containing invalid PRODUCTIDs to some valid value, or delete them.