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

FOR loop not working
Hi,
Anyone can help , this for loop not working in class but working on System Log.
Error:
![]() | Error: Compile Error: expecting right curly bracket, found 'for' at line 5 column 0 |
List <optedOutList> = new List<contact>();
List <activeContactList> = new List<contact>();
List networkList = [SELECT id,name,Account_Name__r.Name, Title__c,Industry__c FROM Contact WHERE Industry__c like :IndustryName AND OptOut__c = false ORDER BY Name ASC LIMIT 100];
for(Contact contactObject: networkList)
{
if(contactObject.OptOut__c==true)
{
optedOutList.add(contactObject);
}
else if(contactObject.active==true)
{
activeContactList.add(contactObject);
}
}
Should be:
Hi, Thanks!
But still same error.
Regards,
mktg
You'd need to send the class declarations, that right-curly bracket error is usually caused by mismatching braces/brackets, so it could be happening anywhere in your class/trigger.
Hi,
Here is the complete class
public class PublicSearchController {
List <contact> optedOutList = new List<contact>();
List <contact> activeContactList = new List<contact>();
List <contact> networkList = [SELECT id,name,Account_Name__r.Name, Title__c,Industry__c FROM Contact WHERE Industry__c like :IndustryName AND OptOut__c = false ORDER BY Name ASC LIMIT 100];
for(Contact contactObject: networkList)
{
if(contactObject.OptOut__c==true)
{
optedOutList.add(contactObject);
}
else if(contactObject.active==true)
{
activeContactList.add(contactObject);
}
}
}
'Active' is not a standard field on contacts. If it's a custom field, it may be called 'Active__c', so you'd instead say:
contactObject.Active__c == true
You'll also need to select it in the SOQL statement where you get the contacts for networkList
Still not working .For loop is not working in normal mode also.
Hello,
I am facing the same problem. Did you find the reason?
Thanks,
Sally