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
SalesForce DummySalesForce Dummy 

Issue with APEX code

OK. I've been doing this for years and suddenly I'm getting an error("expecting right curly bracket, found 'For'"). Here's the class. Can anyone tell me why I'd be getting this error for my FOR statement?

publicwithsharingclass Monthly
{
     public List<Id> lstBudId = new List<Id>();
     publicSet<Id> setBudId = newSet<Id>();

     //Get list of budget periods that are older than today
     public List<Budget_Period__c> lstCBP = new List<Budget_Period__c>
          ([SELECT ID, BUDGET__C
          FROMBudget_Period__c
          WHERE PERIOD_END_DATE__C >= TODAY]);
 

     For(Budget_Period__c cbp : lstCBP)
     {
         
if(!setBudID.contains(cbp.Budget__c))
          {
               setBudId.add(cbp.Budget__c);
               lstBudID.add(cbp.Budget__c);
          }
     }
}

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You look to be missing a method here - you have declared your getter/setter and then it looks like you've jumped straight into code.

All Answers

bob_buzzardbob_buzzard

You look to be missing a method here - you have declared your getter/setter and then it looks like you've jumped straight into code.

This was selected as the best answer
SalesForce DummySalesForce Dummy

Yup. That was it. I'm guessing I need more sleep.

 

Thanks for your quick and accurate response.