You need to sign in to do that
Don't have an account?
Rafael Suarez 14
Can you write up a class and batch it from an execute anonymous block?
Is it possible to use the batchable class in an anonymous block?
I'm attempting to update to a few hundred accounts from within the Execute Anonymous environment, but because of the existing Apex, Im getting "Too many SOQL queries: 50001".
So I attempted the following code (still within an anonymous block) and it will come back with
"Execute Anonymous Error
Line: 13, Column: 14
Global type must be contained inside of a global class"
I think the developer console doesn't like global classes... Does it ?
Do I absolutely need a global modifier to use the SFDC batchable classes ?
Advise will be appreciated
This is the actual code:
RSM
I'm attempting to update to a few hundred accounts from within the Execute Anonymous environment, but because of the existing Apex, Im getting "Too many SOQL queries: 50001".
So I attempted the following code (still within an anonymous block) and it will come back with
"Execute Anonymous Error
Line: 13, Column: 14
Global type must be contained inside of a global class"
I think the developer console doesn't like global classes... Does it ?
Do I absolutely need a global modifier to use the SFDC batchable classes ?
Advise will be appreciated
This is the actual code:
global class SICS implements Database.Batchable<Account>{ global final String Query; string q = 'Select Id, CMSIC8A__c, Temp_BadCMSIC__c from Account' + 'where Temp_BadCMSIC__c != NULL '; global UpdateAccountFields(String q){ Query=q;} global Database.querylocator start(Database.BatchableContext BC){ return Database.getQueryLocator(query);} global void execute(Database.BatchableContext BC, List<Account> scope){ LIST<Account> SIC2Up = [Select Id, CMSIC8A__c, Temp_BadCMSIC__c from Account where Temp_BadCMSIC__c != '']; List <Account> Acc2Up = new List<Account>(); for(Account acc : scope){ IF(acc.Temp_BadCMSIC__c != NULL){ acc.CMSIC8A__c = acc.Temp_BadCMSIC__c; } Acc2Up.add(acc); } Update Acc2Up; } } // SICS obj = new SICS(); Id batchJobId = Database.executeBatch(new SICS(),200);Thanks
RSM
"The Execute Anonymous tool doesnt like global classes"
Then execute below code form your anonymous block
Let us know if this will help you
Thanks for trying to help. Unfortunately your snippet begets the same error message that mine does; "Line: 1, Column: 14
Global type must be contained inside of a global class"... As Charisse stated, it seems the anonymous console does not allow this.
Then execute below code form your anonymous block
Let us know if this will help you