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
SriniSrini 

Compile Error: expecting right curly bracket, found 'else' at line

Hi Everyone,

When we are executing my code we are getting compile error.code is mentioned below.Please check and let us know where we have made the mistakes in the Code.
for(Opportunity ot : scope){
              String Subject= (String)ot.get(Schema.OpenActivities.Description);            
                if(Subject!=Null){
                     for(OpenActivities OPA : ot.getSObjects('OpenActivities')){
                         alist.add(OPA.id);      
                     }
                    else{
                         for(OpportunityTeamMembers  optm: ot.getSObjects('OpportunityTeamMembers')){
                              Plist.add(optm.id);   
                         }                      
                    }
                }
          }
Thanks in Advance
 
Subash ChandraboseSubash Chandrabose

Try this. you miss placed in if condition curly brace

for(Opportunity ot : scope){
    String Subject= (String)ot.get(Schema.OpenActivities.Description);            
    if(Subject!=Null){
        for(OpenActivities OPA : ot.getSObjects('OpenActivities')){
            alist.add(OPA.id);      
        }
    } else{
        for(OpportunityTeamMembers  optm: ot.getSObjects('OpportunityTeamMembers')){
            Plist.add(optm.id);   
        }                      
    }
}
SriniSrini
Hi@Subash,

Thanks for the quick reply. Working fine but we are getting another error like " Invalid type: OpenActivities at line" 

   List<OpenActivities> alist=New List<OpenActivities>();
  Is any another way to use list for OpenActivities?  And why am getting this error.

please help us.

Thanks.
Subash ChandraboseSubash Chandrabose
Actually what is OpenActivities? Is it a custom object?
SriniSrini
Hi@MSCB
Sorry Mentioened wrong name..

@MSCB .

we are getting another error like " Invalid type: OpenActivities at line" 

   List<OpenActivities> alist=New List<OpenActivities>();
  Is any another way to use list for OpenActivities?  And why am getting this error.

please help us.
SriniSrini
open Activities is nothing but one of the related list on the Opportunity