Skip to main content
added 139 characters in body
Source Link
Rahul Gawale
  • 12.3k
  • 6
  • 33
  • 70

I should see this debug: "Batch starts" but this debug does not exist. Variables didn't changedchange too. What should I do so that I could see debugs and modify variables in the execute method? I have this code to run batch:

        Database.executeBatch(new PatchPanelTriggerClassTestBatch());

And this is code for batch:

global with sharing class PatchPanelTriggerClassTestBatch implements Database.batchable<SObject> {

    @TestVisible
    private static Boolean flagForTest = false;

    public static Integer toRemove = 0;

    global void execute(Database.BatchableContext param1, List<Patch_Panel__c> param2) {
        System.debug('Batch starts');
        flagForTest = true;

        for (Patch_Panel__c p : param2) {
            System.debug(p.Name);
            PatchPanelTriggerClass.deleteDuplicates(p.Name);
            List<Interface__c> records = [SELECT Name, Id, Status__c, Port_No__c, Rack__c, Show_in_Customer_Portal__c FROM Interface__c where Name LIKE :p.Name];
            if (thereIsNoDuplicates(records) == false) {
                flagForTest = false;
            }
            toRemove++;

        }
        System.debug('Batch ends');
    }

    static Boolean thereIsNoDuplicates(List<Interface__c> records) {
        // body of method
    }

    global void finish(Database.BatchableContext param1) {
    }

    global Database.QueryLocator start(Database.BatchableContext param1) {
        String s = 'select Name, Total_No_of_Ports__c from Patch_Panel__c';

        return Database.getQueryLocator(s);
    }
}

}

I should see this debug: "Batch starts" but this debug does not exist. Variables didn't changed too. What should I do so that I could see debugs and modify variables in execute method? I have this code to run batch:

        Database.executeBatch(new PatchPanelTriggerClassTestBatch());

And this is code for batch:

global with sharing class PatchPanelTriggerClassTestBatch implements Database.batchable<SObject> {

@TestVisible
private static Boolean flagForTest = false;

public static Integer toRemove = 0;

global void execute(Database.BatchableContext param1, List<Patch_Panel__c> param2) {
    System.debug('Batch starts');
    flagForTest = true;

    for (Patch_Panel__c p : param2) {
        System.debug(p.Name);
        PatchPanelTriggerClass.deleteDuplicates(p.Name);
        List<Interface__c> records = [SELECT Name, Id, Status__c, Port_No__c, Rack__c, Show_in_Customer_Portal__c FROM Interface__c where Name LIKE :p.Name];
        if (thereIsNoDuplicates(records) == false) {
            flagForTest = false;
        }
        toRemove++;

    }
    System.debug('Batch ends');
}

static Boolean thereIsNoDuplicates(List<Interface__c> records) {
    // body of method
}

global void finish(Database.BatchableContext param1) {
}

global Database.QueryLocator start(Database.BatchableContext param1) {
    String s = 'select Name, Total_No_of_Ports__c from Patch_Panel__c';

    return Database.getQueryLocator(s);
}

}

I should see this debug: "Batch starts" but this debug does not exist. Variables didn't change too. What should I do so that I could see debugs and modify variables in the execute method? I have this code to run batch:

Database.executeBatch(new PatchPanelTriggerClassTestBatch());

And this is code for batch:

global with sharing class PatchPanelTriggerClassTestBatch implements Database.batchable<SObject> {

    @TestVisible
    private static Boolean flagForTest = false;

    public static Integer toRemove = 0;

    global void execute(Database.BatchableContext param1, List<Patch_Panel__c> param2) {
        System.debug('Batch starts');
        flagForTest = true;

        for (Patch_Panel__c p : param2) {
            System.debug(p.Name);
            PatchPanelTriggerClass.deleteDuplicates(p.Name);
            List<Interface__c> records = [SELECT Name, Id, Status__c, Port_No__c, Rack__c, Show_in_Customer_Portal__c FROM Interface__c where Name LIKE :p.Name];
            if (thereIsNoDuplicates(records) == false) {
                flagForTest = false;
            }
            toRemove++;

        }
        System.debug('Batch ends');
    }

    static Boolean thereIsNoDuplicates(List<Interface__c> records) {
        // body of method
    }

    global void finish(Database.BatchableContext param1) {
    }

    global Database.QueryLocator start(Database.BatchableContext param1) {
        String s = 'select Name, Total_No_of_Ports__c from Patch_Panel__c';

        return Database.getQueryLocator(s);
    }
}
Source Link

Why execute method doesn't run in batch in this code?

I should see this debug: "Batch starts" but this debug does not exist. Variables didn't changed too. What should I do so that I could see debugs and modify variables in execute method? I have this code to run batch:

        Database.executeBatch(new PatchPanelTriggerClassTestBatch());

And this is code for batch:

global with sharing class PatchPanelTriggerClassTestBatch implements Database.batchable<SObject> {

@TestVisible
private static Boolean flagForTest = false;

public static Integer toRemove = 0;

global void execute(Database.BatchableContext param1, List<Patch_Panel__c> param2) {
    System.debug('Batch starts');
    flagForTest = true;

    for (Patch_Panel__c p : param2) {
        System.debug(p.Name);
        PatchPanelTriggerClass.deleteDuplicates(p.Name);
        List<Interface__c> records = [SELECT Name, Id, Status__c, Port_No__c, Rack__c, Show_in_Customer_Portal__c FROM Interface__c where Name LIKE :p.Name];
        if (thereIsNoDuplicates(records) == false) {
            flagForTest = false;
        }
        toRemove++;

    }
    System.debug('Batch ends');
}

static Boolean thereIsNoDuplicates(List<Interface__c> records) {
    // body of method
}

global void finish(Database.BatchableContext param1) {
}

global Database.QueryLocator start(Database.BatchableContext param1) {
    String s = 'select Name, Total_No_of_Ports__c from Patch_Panel__c';

    return Database.getQueryLocator(s);
}

}