You need to sign in to do that
Don't have an account?
compiler error in controller
Hi Guys,
Can anybody please tell me why I am getting this error:
Error: Customerecommendedcontroller Compile Error: Expecting '}' but was: 'for' at line 14 column 1
Controlller is as follows-
public class Customerecommendedcontroller {
public Account ac;
integer Quarter = Date.Today().Month()/3;
Public List<recommended_Steps__c> totestList{
get{
List<recommended_Steps__c> totestList= [select Quarter__c from recommended_Steps__c where Account__r.id = :ac.id];
retrun totalList;
}
set{}
}
for(recommended_Steps__c rc : totestList )
{
if(Quarter == Quarter__c){
Check__c = true;
}
else
Check__c = false;
}
update rc;
totestList.add(rc);
public list<recommended_Steps__c> recom{
get{
List<recommended_Steps__c> recom = [select id, Account__c,Due_date__c,Steps_to_taken__c,Subject__c,recommended_Steps__c.Sprint__r.End_Date__c from recommended_Steps__c where Account__r.id = :ac.id and Check__c= true];
return recom;
}
set{
}
}
public Customerecommendedcontroller(ApexPages.StandardController controller) {
ac=(Account)controller.getrecord();
}
}
Thanks in Advance :)
https://trailhead.salesforce.com/en/modules/apex_database/units/apex_database_intro
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_reference.htm
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you
thanks
All Answers
Thanks for the quick reply.
I have made the changes but still getting the same error.
updated controller-
public class Customerecommendedcontroller {
public Account ac;
integer Quarter = Date.Today().Month()/3;
Public List<recommended_Steps__c> totestList{
get{
List<recommended_Steps__c> totestList= [select Quarter__c from recommended_Steps__c where Account__r.id = :ac.id];
retrun totalList;
}
set{}
}
for(recommended_Steps__c rc : totestList )
{
if(Quarter == rc.Quarter__c){
rc.Check__c = true;
}
else
rc.Check__c = false;
}
update rc;
totestList.add(rc);
public list<recommended_Steps__c> recom{
get{
List<recommended_Steps__c> recom = [select id, Account__c,Due_date__c,Steps_to_taken__c,Subject__c,recommended_Steps__c.Sprint__r.End_Date__c from recommended_Steps__c where Account__r.id = :ac.id and Check__c= true];
return recom;
}
set{
}
}
public Customerecommendedcontroller(ApexPages.StandardController controller) {
ac=(Account)controller.getrecord();
}
}
error-
Error: Customerecommendedcontroller Compile Error: Expecting '}' but was: 'for' at line 14 column 1
Thanks a lot.
Tried your optimized code.
public class Customerecommendedcontroller {
public Account ac;
integer Quarter = Date.Today().Month()/3;
Public List<recommended_Steps__c> totestList{
get{
List<recommended_Steps__c> totestList= [select Quarter__c from recommended_Steps__c where Account__r.id = :ac.id];
retrun totalList;
}
set{}
}
public List<recommended_Steps__c> lstForUpdate = new List<recommended_Steps__c>();
for(recommended_Steps__c rc : totestList ){
if(Quarter == rc.Quarter__c){
rc.Check__c = true;
}else{
rc.Check__c = false;
}
lstForUpdate.add(rc);
}
if(lstForUpdate.size() > 0){
update lstForUpdate;
}
public list<recommended_Steps__c> recom{
get{
List<recommended_Steps__c> recom = [select id, Account__c,Due_date__c,Steps_to_taken__c,Subject__c,recommended_Steps__c.Sprint__r.End_Date__c from recommended_Steps__c where Account__r.id = :ac.id and Check__c= true];
return recom;
}
set{}
}
public Customerecommendedcontroller(ApexPages.StandardController controller) {
ac=(Account)controller.getrecord();
}
}
But still getting this error-
Error: Customerecommendedcontroller Compile Error: Expecting '}' but was: 'for' at line 16 column 1
I dont know what we are missing.
Thanks a lot.
https://trailhead.salesforce.com/en/modules/apex_database/units/apex_database_intro
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_reference.htm
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you
thanks
Will surely try to improve and learn.
Thanks for your support.
On my Detail page I am getting an error where I am displaying VF page.
Content cannot be displayed: DML currently not allowed
Can you please suggest something?
Thanks
Thank you