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

Method argument error

Hi There. I'm wondering if anyone has ever received this error before?

I am completely bewildered by this one...


The error message states 

Argument 1 cannot be null


Here is my code that is giving me the problem:



private void constructBarWidths(Rig__c rigRec, List<Opportunity> rigOpportunities, List<Contract> rigContracts) { //For each Opportunity we need: //Opportunity name, stage, Contract Start date, Global End date if(rigOpportunities != null && rigOpportunities.size()>0) { for(Opportunity o : rigOpportunities) { if(o.Start_Date__c != null) {


 The error happens at the for loop.

I don't get it because I do a check on Argument 1 (aka rigOpportunities)  to make sure it is not null AND it's size is greater than 0...

Any ideas?





Maybe it's not about your for loop, and more about the method call.

Are you using Eclipse to program and is Eclipse the one giving you the error??

Sometimes I have found that Eclipse shows errors on the right line number but when you double click the error to go there, it goes to the wrong class or trigger, but to the right line number. Make sure you read your error message and it's source carefully because I've seen Eclipse screw it up before.


Other than that though, I'm completely baffled as well.

Message Edited by Whyser on 03-11-2009 01:47 PM

Thanks for the reply.

I'm not using Eclipse. I'm coding through the org.

I'm not sure Eclipse could help me in this instance because the error I get is a

runtime error, not compile time.


Got it!

My mistake.

Basically I was missing a check further down in my code

to make sure the end date opportunity field (custom) was not null.

This variable was an argument to a date method - monthsBetween.

Happy days.

Thanks for the help