Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8317303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:33:40+00:00 2026-06-08T21:33:40+00:00

I am creating a class which will eventually update records on a schedule using

  • 0

I am creating a class which will eventually update records on a schedule using batch APEX. I am having trouble writing an inner class and have tried every possible combination of syntax that i can think of.

Code:

public with sharing class AddendumsExpired {

    public List<Id> opportunityIds{get;set;}
    public List<Id> addendumIds{get;set;}

    public List<Id> OppIds(){

        for(Opportunity thisOpp :[SELECT Id,StageName,Name,Addendum_Amount__c,Addendum_Amount_No_Discounts__c,Agreement_Balance__c FROM Opportunity WHERE (NOT StageName LIKE '%Proposed%') AND (NOT StageName LIKE '%Accepted%')]){
            opportunityIds.add(thisOpp.Id);
        }

        return opportunityIds;
    }

    public List<Id> AddIds(){

        for(Addendum__c thisAdd :[SELECT Id FROM Addendum__c WHERE Opportunity__c IN :opportunityIds AND Expiration__c < TODAY]){
            addendumIds.add(thisAdd.Id);
        }

        return addendumIds;
    }

    public class debugging {
        system.debug('opportunityIds :: '+opportunityIds);
        system.debug('addendumIds :: '+addendumIds);
        system.debug('OppIds() :: '+OppIds());
        system.debug('AddIds() :: '+AddIds());
    }
}

I am still in the testing stage, and the debugging class is throwing an error. I will need to have multiple inner classes for the final production deployment.

I have used the syntax above (public class classname {) before without any issues. However, when I execute anonymous this block of code I receive the error:

Compile error at line 24 column 8
unexpected token: 'class'

If anyone can shed some light on this situation I would really appreciate it! I’m puzzled and wondering why that syntax can work in a dozen other classes but not this one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:33:41+00:00Added an answer on June 8, 2026 at 9:33 pm

    The code in your class:

    public class debugging {
            system.debug('opportunityIds :: '+opportunityIds);
            system.debug('addendumIds :: '+addendumIds);
            system.debug('OppIds() :: '+OppIds());
            system.debug('AddIds() :: '+AddIds());
        }
    

    is incorrectly placed in the declarations section and not where any actual code should be (excluding statics, getters and setters).

    Place the system.debug code within a method inside of your inner-class (perhaps the constructor) and it will compile and run just fine. Of course then you need to instantiate your debugging class first so it has an instance to execute the code it contains.

    Like this:

    public class Debugging 
    {
       public Debugging(List<Id> opportunityIds)
       {
          system.debug('opportunityIds :: '+opportunityIds);
       }
    }
    

    Then you can create an instance to execute these debug statements, passing in your opportunityIds list into the constructor of your inner-class:

    Debugging d = new Debugging(opportunityIds);
    

    EDIT:

    Change your getters and setters to the following. These contain proper initialization code for your lists (using retVal to declare a new List in each):

    public List<Id> opportunityIds
    {
       get
       {
          List<Id> retVal = new List<Id>();
          for(Opportunity thisOpp :[SELECT Id,StageName,Name FROM Opportunity WHERE (NOT StageName LIKE '%Proposed%') AND (NOT StageName LIKE '%Accepted%')])
          {
             opportunityIds.add(thisOpp.Id);
          }
          return retVal;
       }
       private set;
    }
    
    public List<Id> addendumIds
    {
       get
       {
          List<Id> retVal = new List<Id>();
          for(Addendum__c thisAdd :[SELECT Id FROM Addendum__c WHERE Opportunity__c IN :opportunityIds AND Expiration__c < TODAY])
          {
             addendumIds.add(thisAdd.Id);
          }
          return retVal;
       }
       private set;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a class that will have one public method, which returns a value
Consider this... I am writing a class named Cache which will accept either a
I am currently creating a class to handle all my form data which will
I am creating an UI class in which everything will run (a different class
I'm creating a class which will contain a list of IP addresses, as Net::IP
I have an interface, IMessage and a class which have several methods for creating
Suppose you are creating a class with multiple .cpp files (which each contain the
I frequently find myself creating classes which use this form (A): abstract class Animal
I am creating some xsl to transform my xml into text (which will be
I am creating a notification class which uses the session to store messages. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.