1

I get this compile error:

Error is line 20 unexpected token: ':'

but can't see why. The class is:

public class Consent_Records_Ctrl1 {
    public date startDate{get;set;}
    public date EndDate{get;set;}
    public  long store{get;set;}
    public List<WrapConsent> allCon{get;set;}
    public List<Consent__c> allConRecs{get;set;}
    public map<string,string>MapAccAr=new map<string,string>();
    public PageReference consentFilter() {


    for (AggregateResult groupedResults: [SELECT  Count(Id)ids,Account__r.Id accids FROM Consent__c where CreatedDate >=:startDate AND LastModifiedDate <=:EndDate GROUP BY Account__r.Id]) {
       // System.debug('ID' + ar.get('ids'));
       // System.debug('Count Id' + ar.get('expr0'));
              MapAccAr.put(string.valueof(groupedResults.get('accids')),string.valueof(groupedResults.get('ids')));
    }
    for(Consent__C consent:[select account__r.id,name,Salutation__c,FirstName__c ,Initials__c,LastNamePrefix__c,LastName__c,
            ElectricityCurrentRedeliveryNum__c,ElectricityCurrentRedeliveryLowNum__c ,MeterTariffChoice__c,
            PhoneNumber__C,EmailAddress__c,Main_Street__c,Main_Number__c,Main_Addition__c,Main_PostalCode__c,
            Main_City__c,Exclude_from_Surveys__c from Consent__c where ElectricityCurrentRedeliveryNum__c > 0  and Status__c = 'Processed']
            [ CreatedDate >=:startDate AND LastModifiedDate <=:EndDate]){
               WrapConsent wrapCon=new WrapConsent();
               if(MapAccAr.containsKey(string.valueof(consent.account__r.id)))
               wrapCon.coutOfid=MapAccAr.get(string.valueof(consent.account__r.id));
               wrapCon.accid=string.valueof(consent.account__r.id);
               wrapCon.name=consent.name;
               wrapCon.Salutation=consent.Salutation__c;
               wrapCon.FirstName=consent.FirstName__c;
               wrapCon.Initials=consent.Initials__c;
               wrapCon.LastNamePrefix=consent.LastNamePrefix__c;
               wrapCon.LastName=consent.LastName__c;
               wrapCon.ElectricityCurrentRedeliveryNum=string.valueof(consent.ElectricityCurrentRedeliveryNum__c);
               wrapCon.ElectricityCurrentRedeliveryLowNum=string.valueof(consent.ElectricityCurrentRedeliveryLowNum__c);
               wrapCon.MeterTariffChoice=consent.MeterTariffChoice__c;
               wrapCon.PhoneNumber=string.valueof(consent.PhoneNumber__C);
               wrapCon.EmailAddress=consent.EmailAddress__c;
               wrapCon.Main_Street=consent.Main_Street__c;
               wrapCon.Main_Street=consent.Main_addition__c;
               wrapCon.Main_Number=string.valueof(consent.Main_Number__c);
               wrapCon.Main_PostalCode=consent.Main_PostalCode__c;
               wrapCon.Main_City=consent.Main_City__c;
               wrapCon.Exclude_from_Surveys=string.valueof(consent.Exclude_from_Surveys__c);

                }

            return null;
            return consentFilter();
        }
        public List<WrapConsent> getConsentlist() {
        return allCon;
        }

    public void ConsentDisplay()
        {
            if(startDate!=NULL&&EndDate!=NULL)
            {
                if(startDate!=NULL&&EndDate!=NULL)
                {              
                    store=1;
                }
                else
                {
                    store=0;
                }
            }

        }
        public class WrapConsent{
        public string coutOfid{set;get;}
        public string accid{set;get;}
        public string name{set;get;}
        public string Salutation{set;get;}
        public string FirstName{set;get;}
        public string Initials{set;get;}
        public string LastNamePrefix{set;get;}
        public string LastName{set;get;}
        public string ElectricityCurrentRedeliveryNum{set;get;}
        public string ElectricityCurrentRedeliveryLowNum{set;get;}
        public string MeterTariffChoice{set;get;}
        public string PhoneNumber{set;get;}
        public string EmailAddress{set;get;}
        public string Main_Street{set;get;}
        public string Main_Number{set;get;}
        public string Main_PostalCode{set;get;}
        public string Main_City{set;get;}
        public string Exclude_from_Surveys{set;get;}
        public string Main_addition{set;get;}

    }


}
3

Change the soql your passing inside for loop. You have messed up with square bracket near where clause.

for(Consent__C consent:[select account__r.id, name,Salutation__c, FirstName__c,
                        Initials__c,LastNamePrefix__c,LastName__c,
                        ElectricityCurrentRedeliveryNum__c, ElectricityCurrentRedeliveryLowNum__c , 
                        MeterTariffChoice__c,PhoneNumber__C,EmailAddress__c,Main_Street__c,Main_Number__c, 
                        Main_Addition__c, Main_PostalCode__c,
                        Main_City__c,Exclude_from_Surveys__c from Consent__c 
                        where ElectricityCurrentRedeliveryNum__c > 0  and Status__c = 'Processed'
                        CreatedDate >=:startDate AND LastModifiedDate <=:EndDate])             
  • 1
    Can you add to this answer detail of what you have changed and perhaps rephrase to say "Change" not "Check"? – Keith C Aug 10 '17 at 7:02
  • Still a bit hard to see the change but +1 from me. – Keith C Aug 10 '17 at 7:22
  • @KeithC Thank You... – NITHESH K Aug 10 '17 at 7:41
  • Thank you Nitesh can you help me display the oldest consent__c.ID as well on the report. – NCSS Aug 10 '17 at 8:44
  • Oldest consent__C.ID in term of what condition your telling?. Already you are fetching Consent__c based on "CreatedDate >=:startDate " this condition. Oldest means you wanted fetch "Consent__c" based on "CreatedDate <=:startDate this condition. – NITHESH K Aug 10 '17 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.