You need to sign in to do that
Don't have an account?

Trying to use AggregateResult for the first time, getting error " Missing '<EOF>' at 'public' "
Hello,
I am trying to use AggregateResult to build a controller for a VF page. This is the fist time that I am using this function and am recieving the error:
I have googled this like crazy, and seem to understand that it is because I have markup outside of the wrapper but I still can't understand how to fix it? Can anyone help?
Here is my class:
Thank you so much for any help!
John
I am trying to use AggregateResult to build a controller for a VF page. This is the fist time that I am using this function and am recieving the error:
Error: Compile Error: Missing '<EOF>' at 'public' at line 10 column 1
I have googled this like crazy, and seem to understand that it is because I have markup outside of the wrapper but I still can't understand how to fix it? Can anyone help?
Here is my class:
public class CurrentWeekDY{ String Campaign {get; set;} String Delivery {get; set;} public DelSum(string c, string d){ this.Campaign=c; this.Delivery=d; } } public List<DelSum> DelSumList = new List<DelSum>(); public List<DelSum> getDelSumOut(){ AggregateResult[] AgR = [SELECT Campaign_TL__c, SUM(Spend__c) FROM TL_Client__c WHERE CWDelivery__c = TRUE GROUP BY Campaign_TL__c ORDER BY Campaign_TL__c]; for (AggregateResult DYList : AgR) { DelSumList.add(new DelSum(String.valueOf(DYList.get('Campaign_TL__c')), String.valueOf(DYList.get('expr0')), String.valueOf(DYList.get('expr1')))); } return DelSumList; }
Thank you so much for any help!
John
string c - which is being copied to this.Campaign
string d - which is being copied to this.Delivery
on line #18 you are creating a new DelSum class, which is calling the constructor on line #6. You are calling with 3 parameters, but it is only defined with 2 parameters.
what is 'expr0' supposed to be, and what is 'expr1' supposed to be? Double check your SOQL query on line #15, make sure you are passing the right parameters in the right order on line #18, then make sure the constructor definition on line #6 matches your reference on line #18.
Does this make sense, or did I lose you with these steps?
All Answers
You had a bracket on line #9 that should have been after line #18. I moved it and reformatted the code, so please compare it to your prior code to learn where you went wrong. You can help prevent these sorts of common mishaps by keeping your code clean, formatted, and indented.
Please mark this answer as correct if it helped you.
Moving the bracket cleared the error, but opened up another on line 12: "Invalid type: DelSum at line 12 column 21". I'll have to go back to the drawing board on that one!
add class to above line
Hope this helps you.
Thanks
Varaprasad
When I try the code you supplied I am getting
string c - which is being copied to this.Campaign
string d - which is being copied to this.Delivery
on line #18 you are creating a new DelSum class, which is calling the constructor on line #6. You are calling with 3 parameters, but it is only defined with 2 parameters.
what is 'expr0' supposed to be, and what is 'expr1' supposed to be? Double check your SOQL query on line #15, make sure you are passing the right parameters in the right order on line #18, then make sure the constructor definition on line #6 matches your reference on line #18.
Does this make sense, or did I lose you with these steps?
Ohh! I can't believe I missed that!
I origionally had 3 parameters, then cut it down to 2 before I got stuck... and forgot to update line 18. Thank you so much.
Gosh I'm dense!