+ Start a Discussion
Mike_M_2Mike_M_2 

Urgent. OpportunityControllerExtension suddenly can't find opportunitysplits

This has been working in production for around a year and suddenly it stopped working over the weekend. 

 

below is the initialization section of the OpportunityControllerExtension

followed by the debugging log showing the error.

I've highlighted the offending line of code in RED.

 

This same code worked in Prod up until this weekend, and the same code also works perfectly in Sandbox. 

 

I have users who are up in arms, so any help would be appreciated.

Thanks,

Mike

 

 

public with sharing class OpportunityControllerExtension {

   private final Opportunity opp;
   private final Opportunity currentOpportunity;
   private final Account billingAccount;
   private final Account agency;
   
   private aaWSDLBeans.CampaignInfo[] campaignInfo;
   private List<OpportunitySplit> splitList;
   private List<OpportunityPartner> agencyList;
   private List<Revenue_Forecast__c> newRevenueForecasts;
   public  boolean debug;
   
   public OpportunityControllerExtension(ApexPages.StandardController stdController) {
      currentOpportunity = (Opportunity)stdController.getRecord();
      debug = false;
      this.opp = [
         SELECT
              o.StageName
            , o.Name
            , o.Estimated_Revenue_Start_Date__c
            , o.Estimated_Revenue_End_Date__c
            , o.campaign_total__c
            , o.OwnerId
            , o.AccountId
            , o.AutoIO__c
            , o.I_O__c
            , o.PO__c
            , o.account.type
            , o.account.Category__c
            , o.account.sub_category__c
            , o.billing_io_key__c
            , o.account.platform_id__c
            , o.account.agency_name__r.id
            , o.account.agency_name__r.name
            , o.account.parent.name
            , o.account.name 
            , o.account.owner.name 
            , o.account.Primary_Campaign_Manager__c 
            , o.account.owner.email 
            , o.account.BillingStreet 
            , o.account.CS_Login_First_Name__c 
            , o.account.BillingCity 
            , o.account.CS_Login_Last_Name__c  
            , o.account.BillingState 
            , o.account.Website 
            , o.account.BillingPostalCode 
            , o.account.Account_Email__c 
            , o.account.BillingCountry       
            , o.account.Phone       
             ,   (SELECT Month__c, Split_Owner__r.Name, Revenue__c, Split__c, Split_Revenue__c 
                    FROM Revenue_Forecasts__r order by Month__c, Split_Owner__r.Name)
         FROM Opportunity o
         WHERE o.id = :currentOpportunity.id];

      /*this.billingAccount = currentOpportunity.account;*/
      this.billingAccount = opp.account;
      this.agency = opp.account.agency_name__r;           
  
      this.splitList = [
         Select o.SplitPercentage, o.SplitOwnerId, o.SplitAmount
         From OpportunitySplit o
         Where o.OpportunityId = :currentOpportunity.id];
         
      if (splitList.isEmpty()) {
         splitList = new List<OpportunitySplit>();
         splitList.add(new OpportunitySplit(OpportunityId = opp.id, 
                           SplitOwnerId = opp.OwnerId, SplitPercentage = 100));
      }
      calcNewRevenueForecasts();
   }

12:01:11.275 (275088000)|SOQL_EXECUTE_BEGIN|[17]|Aggregations:1|select o.StageName, o.Name, o.Estimated_Revenue_Start_Date__c, o.Estimated_Revenue_End_Date__c, o.campaign_total__c, o.OwnerId, o.AccountId, o.AutoIO__c, o.I_O__c, o.PO__c, o.account.type, o.account.Category__c, o.account.sub_category__c, o.account.platform_id__c, o.account.agency_name__r.id, o.account.agency_name__r.name, o.account.parent.name, o.account.name, o.account.owner.name, o.account.owner.email, o.account.Primary_Campaign_Manager__c, o.account.BillingStreet, o.account.CS_Login_First_Name__c, o.account.BillingCity, o.account.CS_Login_Last_Name__c, o.account.BillingState, o.account.Website, o.account.BillingPostalCode, o.account.Account_Email__c, o.account.BillingCountry, o.account.Phone, o.billing_io_key__c, (select Month__c, Split_Owner__r.Name, Revenue__c, Split__c, Split_Revenue__c from Revenue_Forecasts__r order by Month__c, Split_Owner__r.Name) from Opportunity o where o.id = :tmpVar1
12:01:11.330 (330646000)|SOQL_EXECUTE_END|[17]|Rows:1
12:01:11.331 (331377000)|SOQL_EXECUTE_BEGIN|[60]|Aggregations:0|select o.SplitPercentage, o.SplitOwnerId, o.SplitAmount from OpportunitySplit o where o.OpportunityId = :tmpVar1
12:01:11.384 (384942000)|EXCEPTION_THROWN|[60]|System.QueryException: null
12:01:11.385 (385075000)|SYSTEM_MODE_EXIT|false
12:01:11.385 (385245000)|CODE_UNIT_FINISHED|OpportunityControllerExtension <init>
Best Answer chosen by Admin (Salesforce Developers) 
Mike_M_2Mike_M_2

I found the problem. It is related to this statement, "OpportunitySplit credits one or more opportunity team members with a portion of the opportunity amount. This object is available in API version 16.0 and later for pilot customers, and version 28.0 and later for others."

 

My OpportunityControllerExtension was Version 25. It looks to me that when Salesforce went to version 28, we were no longer flagged as a "pilot customer". This means that the OpportunityControllerExtension needs to be 28 or greater in order to access opportunitysplits. I set the version to 29 and now everything works again.

All Answers

k_bentsenk_bentsen

The exception information in the debug log is pretty vague, have you tried wrapping the SOQL query in a try/catch block so you can get more detail on the exception that's being thrown?

Mike_M_2Mike_M_2
I'll try that, thx
Mike_M_2Mike_M_2

I put in the following try/catch but it does not give much more information than the original.

 

try {
this.splitList = [
Select o.SplitPercentage, o.SplitOwnerId, o.SplitAmount
From OpportunitySplit o
Where o.OpportunityId = :currentOpportunity.id];

} catch(DmlException e) {
System.debug('The following DML exception has occurred: ' + e.getMessage());
} catch(Exception e) {
System.debug('The following exception has occurred: ' + e.getMessage());
}

/* if (splitList.isEmpty()) { */
if (TRUE) {
splitList = new List<OpportunitySplit>();
splitList.add(new OpportunitySplit(OpportunityId = opp.id,
SplitOwnerId = opp.OwnerId, SplitPercentage = 100));
}

 

Here is the log output.

 

15:56:51.310 (2310673000)|SOQL_EXECUTE_BEGIN|[61]|Aggregations:0|select o.SplitPercentage, o.SplitOwnerId, o.SplitAmount from OpportunitySplit o where o.OpportunityId = :tmpVar1

15:56:51.373 (2373763000)|EXCEPTION_THROWN|[61]|System.QueryException: null

15:56:51.374 (2374024000)|SYSTEM_METHOD_ENTRY|[69]|System.QueryException.getMessage()

15:56:51.374 (2374084000)|SYSTEM_METHOD_EXIT|[69]|System.QueryException.getMessage()

15:56:51.374 (2374113000)|SYSTEM_METHOD_ENTRY|[69]|System.debug(ANY)

15:56:51.374 (2374130000)|USER_DEBUG|[69]|DEBUG|The following exception has occurred: null

 

What am I doing wrong? 

 

 

k_bentsenk_bentsen

Doesn't look like you're doing anything wrong, the fact that the exceptions getMessage() is returning null is pretty odd behavior. See if the getStackTraceString() method provides anymore detail.

Mike_M_2Mike_M_2
ok, will do, thanks.
Mike_M_2Mike_M_2

Nothing particularly revealing here either.

 

17:26:06.270 (270991000)|USER_DEBUG|[66]|DEBUG|QEXCEPTION MESSAGE     -->>>: null

17:26:06.270 (270999000)|SYSTEM_METHOD_EXIT|[66]|System.debug(ANY)

17:26:06.271 (271018000)|SYSTEM_METHOD_ENTRY|[67]|Exception.getStackTraceString()

17:26:06.271 (271059000)|SYSTEM_METHOD_EXIT|[67]|Exception.getStackTraceString()

17:26:06.271 (271073000)|SYSTEM_METHOD_ENTRY|[67]|System.debug(ANY)

17:26:06.271 (271083000)|USER_DEBUG|[67]|DEBUG|QEXCEPTION STACK TRACE -->>>: Class.OpportunityControllerExtension.<init>: line 61, column 1

17:26:06.271 (271090000)|SYSTEM_METHOD_EXIT|[67]|System.debug(ANY)

17:26:06.271 (271109000)|SYSTEM_METHOD_ENTRY|[68]|Exception.getTypeName()

17:26:06.271 (271139000)|SYSTEM_METHOD_EXIT|[68]|Exception.getTypeName()

17:26:06.271 (271152000)|SYSTEM_METHOD_ENTRY|[68]|System.debug(ANY)

17:26:06.271 (271161000)|USER_DEBUG|[68]|DEBUG|QEXCEPTION TYPE NAME   -->>>: System.QueryException

k_bentsenk_bentsen

How about just changing your query to:

 

this.splitList = [
         Select SplitPercentage, SplitOwnerId, SplitAmount
         From OpportunitySplit 
         Where OpportunityId = :currentOpportunity.id];

 

 

Mike_M_2Mike_M_2

Okay, I'll give that a try and let you know the results. I don't hold out much hope since the current code already works perfectly in the Sandbox. We'll see.

Mike_M_2Mike_M_2

The result of removing the alias is the same as before. I have a Case into Salesforce. When we find the answer, I will come back here and document it.

 

k_bentsenk_bentsen

This might be a silly question, but did you double check to make sure opportunity splits weren't accidentally disabled in your org, by another admin perhaps?

Mike_M_2Mike_M_2

Yes, it's still enabled. In fact it says on the enable page "Cannot disable Opportunity Splitting when referenced by: Apex Class: OpportunityControllerExtension, Visualforce Page: OppRevenueForecastTemplateCreateB2BTech". But it was worth a look. :-)

 

viadeoviadeo

H,

 

I have same issue do you have any news from Salesforce support ?

Mike_M_2Mike_M_2

They have just today responded and they have not found the problem yet.

Michael J. Moore
Director, Applications Developer
QuinStreet Inc.
950 Tower Lane, 6th Floor
Foster City, CA 94404

Mike_M_2Mike_M_2
Now Salesforce support is telling me this is a code problem so I need to buy Premium support and file a premium case. Instead I am contacting my Account Executive because I don't believe the support girl truly understands that this is NOT bad code but rather a bad response to good code.
Mike_M_2Mike_M_2

I found the problem. It is related to this statement, "OpportunitySplit credits one or more opportunity team members with a portion of the opportunity amount. This object is available in API version 16.0 and later for pilot customers, and version 28.0 and later for others."

 

My OpportunityControllerExtension was Version 25. It looks to me that when Salesforce went to version 28, we were no longer flagged as a "pilot customer". This means that the OpportunityControllerExtension needs to be 28 or greater in order to access opportunitysplits. I set the version to 29 and now everything works again.

This was selected as the best answer