function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ShaTShaT 

System.QueryException: null:

Hi All,

 

I m getting below error while updating Opportunity.

 

System.QueryException: null: 

 

When i query in debug log its works fine, but when i run the Query in class is gives me above exception.

 

Select SplitPercentage, SplitOwnerId, SplitNote, SplitAmount, OpportunityId, Id From OpportunitySplit where OpportunityId!=null and OpportunityId IN('006Z0000007XSSDSSD') limit 50000

 

So any one has any idea where i am going wrong.

 

Thanks

Shailu

 

Best Answer chosen by Admin (Salesforce Developers) 
Mike_M_2Mike_M_2
Change the version number of your trigger to 28 or later.

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

All Answers

Grazitti InteractiveGrazitti Interactive

Hi,

 

Please provide full code, any way there may be following problem in code-

 

I tried following code and its work (replace Opportunity id with your Opportunity id)-

 

List<OpportunitySplit>  ols = [select SplitPercentage, SplitOwnerId, SplitNote, SplitAmount, OpportunityId, Id from OpportunitySplit where (OpportunityId != null and OpportunityId IN ('0069000000DAqGQ')) limit 50000];

 

- Make sure that 006Z0000007XSSDSSD exists. 

-its possible that this qurey does not return any record and you are referencing list ols anywhere in code and do not checking null pointer exception, so check null pointer exception as if(!ols.isEmpty()){}

 

 

/**if this post helps you, please throw a kudos by clicking star**/

 

Thanks,

Grazitti

gbu.varungbu.varun

you can use:

 

List<OpportunitySplit> oprList = [Select SplitPercentage, SplitOwnerId, SplitNote, SplitAmount, OpportunityId, Id From OpportunitySplit where OpportunityId!=null and OpportunityId = :'006Z0000007XSSDSSD' limit 50000];

 

Use it by null check like:

 

if(oprList<>null && oprList.size()>0 ){

 

}

ShaTShaT

Thanks for your Solution Guys..

But the problem is bit different. i m tying to query to OpportunitySplit record which is associated with selected opportunity. If Opportunity stage is close won than it gives me above error and if stage is anything it allows me to save the record.

So Do you have any idea about OpportunitySplit ..?

Grazitti InteractiveGrazitti Interactive

Hi,

 

Please paste full code so that we can understand your problem clearly and can provide an optimised solution. 

 

OpportunitySplits-

 

" Opportunity Splits lets user with appropriate access rights splits credit for Opportunity among members (Opportunity Team)".

 

Revenevue spits: this split provide credits to team member who are directly responsible for revenue.

Overlay spits: this split provide credits to team member who are indirectly responsible for revenue.

 

Please check :

1. Any validation rule, Workflow or Trigger on Opportunity at stage closed won.

2. Debug exception in code.

 

Thanks,

www.grazitti.com

 

 

 

 

Mike_M_2Mike_M_2

Any solution for this, I am having the same problem on code that used to work fine. It's in opportunity controller extension.

 

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

I am running into the same thing. I have the following query within some logic in the Opportunity "after insert" trigger, where the clearUserSalesTeamOpps is a List that contains a single valid Opportunity ID:

 

List<OpportunitySplit> userSalesTeamSplits = [SELECT Id, SplitOwnerId, SplitNote, SplitPercentage, OpportunityId FROM OpportunitySplit WHERE OpportunityId IN :clearUserSalesTeamOpps];

 

This used to work fine until recently but now I get the following error:

 

EXCEPTION_THROWN|[339]|System.QueryException: null

 

It looks to me like there is a query exception but the message in the query exception is null. I don't think it is saying that any of my values/variables are null because that would be a different error message, plus the only variable I have is the clearUserSalesTeamOpps List and I verified that it has a value in it by writing to System.debug just prior to the line that throws the exception.

 

Mike_M_2Mike_M_2
Change the version number of your trigger to 28 or later.

Michael J. Moore
Director, Applications Developer
QuinStreet Inc.
950 Tower Lane, 6th Floor
Foster City, CA 94404
650.578.7657
mmoore@quinstreet.com
This was selected as the best answer
BobbioBobbio
That did the trick! Thanks for the quick reply.
spazmspazm

I've winnowed this down to a minimal test case that fails with API < 28.0

 

public class TestOpSplit {
   public static void TestSplit() {
          System.debug('===The Select===' + [ SELECT OpportunityId FROM OpportunitySplit]);
    }
}

compile with SalesForce.com API v18.

 

Run via Execute Anonymous:

TestOpSplit.TestSplit();

 

 Throws exception:

 

System.QueryException: null: Class.TestOpSplit.TestSplit: line 3, column 1 AnonymousBlock: line 8, column 1 AnonymousBlock: line 8, column 1

Exception is thrown with SalesForce.com API in (v18, v19, v27)

Does not throw exception with SalesForce.com API in (v28, v29)