function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vincent BartolomaVincent Bartoloma 

Scheduled auto Lead creation

I am attempting to distribute Leads from a list on a weekly basis. I have this code which is producing an error : "Global variable must be contained in a global class". I don't understand this since I have the class labeled as global.
 
global class WeeklyPreOppProcessor {
{
    global void execute (SchedulableContext scx)
    {

        Group group = [Select Id, Name FROM Group 
                       WHERE Type = 'Queue' 
                       AND Name = 'Distributed_Queue'];

        List<Lead> lstLead = [SELECT Id, Name, OwnerId 
                              FROM Lead 
                              WHERE Distributed__c = false LIMIT 50];
        for(Lead leadObj:lstLead)
        {
            leadObj.Distributed__c = true;
            leadObj.OwnerId = group.Id;
        }
        update lstLead;
    }

}

Any ideas ?
kirubakaran viswanathankirubakaran viswanathan
Hi,

You have extra open bracket "{" in line 2. Removing that will resolve the issue.
Vincent BartolomaVincent Bartoloma
That definitely helped. I still managed to get an 'Identifier name is reserved: group at line 6 column 15' error. I solved that by changing 'group' to 'group1'.

Thanks for your help !