• Albert Raul
  • NEWBIE
  • 30 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 4
    Replies
Don't want the user to enter a future close date, if they do opportunities with past closed should be entered 
public class FindOpp {    
   public static void function(){
      Date sDate = Date.today().addMonths(-1);
      Date eDate = Date.today();
      List<Account> accList = [SELECT Id, Name, (SELECT Id FROM Opportunity WHERE IsClosed = true AND StageName = 'Closed Won' AND CloseDate >= :sDate AND CloseDate <= :eDate) FROM Account];
     List<Account> AccountData = new List<Account>();
     for (Account acc : accList) {    
         if (acc.Opportunities.size() >= 10) {        
            AccountData.add(acc);    
            }
      }
      for (Account acc : AccountData) {    
          system.debug(acc.Name);
      }    
   }
}

ERROR at Row:1:Column:34 Didn't understand relationship 'Opportunitiy' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.