Skip to main content
3 of 4
added 1444 characters in body
Pranay Jaiswal
  • 36.4k
  • 17
  • 79
  • 138

So you can do at max 100 callouts in a transaction.

As I can see you are Setting batch scope as 50. Database.executebatch(objTest, 50);

As you say, for each Account you will be making 12 Folder ie 12 Callouts.

So in each iteration of execute of Batch, you need 12(Folder) *50 (Account) = 600 callouts.

As we cannot do 600 Callouts in execute, you need to change the scope of your batch to the optimal value.

100(Callout)/12(Folder) = 8.3

that means your scope will be 8.

thus the fix will be:

AccountBoxFolderCreationBatch objTest = new AccountBoxFolderCreationBatch();
Database.executebatch(objTest, 8);

Edit: It looks like more than 1 callouts are used by Box API to create a folder. We have 2 options, try to find out how many callouts are taken by 1 account. We would try calling execute method to see a number of callouts made.

List<Account> AccList=[
            select
                Id, 
                Box_Folder_Id__c, 
                Financial_Accounts_Parent_Box_Folder_Id__c, 
                CLG_Opportunities_Parent_Box_Folder_Id__c, 
                Real_Estate_Assets_Parent_Box_Folder_Id__c, 
                Tax_Documents_Parent_Box_Folder_Id__c, 
                Medical_Records_Parent_Box_Folder_Id__c,
                Funding_Parent_Box_Folder_Id__c,
                Underwriting_Parent_Box_Folder_Id__c,
                Registration_Parent_Box_Folder_Id__c,
                Compliance_Parent_Box_Folder_Id__c,
                Contact_Parent_Box_Folder_Id__c,
                Performance_Reports_Parent_Box_Folder_Id__c,
                Opportunity_Parent_Box_Folder_Id__c
            from Account 
            where RecordTypeId = :householdAccountRTId
            and Box_Folder_Id__c = null limit 1
        ];

new AccountBoxFolderCreationBatch ().execute(null,AccList);
System.debug('Callouts Used are:'+LIMITS.getCallouts());

Once we see the debug log, we can find the optimal batch size needed.

Src: Callout limits

Pranay Jaiswal
  • 36.4k
  • 17
  • 79
  • 138