1

I have a code that works fine:

 public with sharing class Send_noti_emails {

        public PageReference sendpassfail() {

            for (Inquery__c inquery : [SELECT Name,Id,Previous_user__c, Quilification__c,    Final_Email_Date__c, Email__c,First_Name__c, Last_Name__c]){
            }
        }
    }

But i need to change the code so that inquery is a public declaration,

public with sharing class Send_noti_emails {
    public List<Inquery__c > u {get;set;}
    inquery = new Inquery__c();
    public PageReference sendpassfail() {

        for(inquery : [SELECT Name,Id,Previous_user__c, Quilification__c, Final_Email_Date__c, Email__c,First_Name__c, Last_Name__c]){
        }
    }
}

But this gives me an error telling me unexpected : at for(inquery : [SELECT Can someone tell me what i need to change?

3

You forgot the object name

for(inquery : [SELECT Name...];

Should be

for(Inquery__c inquery : [SELECT Name...];

EDIT

If you want to use your controller property u (list of Inquery__c's) then you need to initialize the value in the constructor like below

public Send_noti_emails(){
    u = [SELECT Name,Id,Previous_user__c, Quilification__c, Final_Email_Date__c, Email__c,First_Name__c, Last_Name__c From Inquery__c];
}

Then, you can reference that property in your for loop

for(Inquery__c inquery : u){

}
  • Yes, thats what i had the code originally[see the first code], but i need to declare inquery as a public variable, because i need to call it from my test code. So if i do that, there is no need to do add Inquery__c anymore, is that correct? – user2333346 Oct 9 '13 at 18:08
  • Oh, ok, I see. You need to initialize the value of your list in a class constructor. Updated the code. – Chris Duncombe Oct 9 '13 at 18:13
  • I added these two lines public with sharing class Send_noti_emails { public List<Inquery__c> u{get;set;} 22 u = [SELECT Name,Id,Previous_user__c, Quilification__c, Final_Email_Date__c, Email__c,First_Name__c, Last_Name__c]; But it tells me Error: unexpected token: '=' at line 22 – user2333346 Oct 9 '13 at 18:20
  • Can you update the question so I can read it more clearly. Its likely a simple thing just need to see your code. Update the second code block with the exact code you are using, and then add the error below it – Chris Duncombe Oct 9 '13 at 18:23
  • ok i fixed, i forgot to put the code into a public Send_noti_emails(){}, sorry about that – user2333346 Oct 9 '13 at 18:24

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.