• Satish Palyam
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
Hi Salesforce Developers Community,

We have a need for batch apex where we have around 6M accounts to be updated with right owner, based on custom territory ruels. 

Start Query: As i need to first fetch all the accounts i need to have query where Select field1,field2, field3, field4 from Account which wil return Database.QueryLocator. Since the voulme is so high, can i still go ahead with this logic ? what happens when the Account records are updated in execute method, will this impact Database.QueryLocator to pick up the same records again ?

 
We have a need where we want to push out some records from Salesforce using already defined Outbound Message. However, we donot want to update these records. Currently on create or update outbound message is triggered. However, some of the records gone out-of-sync with backend systems and now we would like to push out the current state of these records wtihout making any changes ont these records. Please adivse the best possible way. 

One way, i could think is the create a custom field and update this field using Data loader, which eventually triggers the outbound message. 
Hi Experts, 

I've created a test class like here. 

@isTest
class TestdeleteOldProcessedUserChangeEntries {
    // CRON expression: midnight on March 15.
    // Because this is a test, job executes
    // immediately after Test.stopTest().
    public static String CRON_EXP = '00 32 17 05 3 ? 2015'; //'0 0 0 15 3 ? 2022';
    static testmethod void test() {
        Test.startTest();
//     Assuming that there are no userchange entries put into the table during testing.. get the table count to compare before and after
  Integer initcount1 = [SELECT COUNT() FROM user_change__c];
system.debug('initcount1' + initcount1);
        // Schedule the test job
        String jobId = System.schedule('deleteOldProcessedUserChangeEntries',
                                       CRON_EXP,
                                       new deleteOldProcessedUserChangeEntries());
        // Get the information from the CronTrigger API object
        CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered,
                          NextFireTime
                          FROM CronTrigger WHERE id = :jobId];
        // Verify the expressions are the same
        System.assertEquals(CRON_EXP,
                            ct.CronExpression);
        // Verify the job has not run
        System.assertEquals(0, ct.TimesTriggered);
        // Verify the next time the job will run
        System.assertEquals('2022-03-15 00:00:00',
                            String.valueOf(ct.NextFireTime));
        // Verify the scheduled job hasn't run yet.
  Integer initcount2 = [SELECT COUNT() FROM user_change__c];
        system.debug('initcount2' +initcount2);
         System.assertEquals(initcount1, initcount2);
        Test.stopTest();
        // Now that the scheduled job has executed after Test.stopTest(),
        // fetch the new merchandise that got added.
  Integer initcount3 = [SELECT COUNT() FROM user_change__c];
        system.debug('initcount3' + initcount3);  
         System.assertEquals(initcount2-initcount3, 1);
    }
}

Select Count is not returning me any count...? any ideas. ?

Please advise.