0
List<Account> Scope = [SELECT id FROM ACCOUNT];
// This is the query being used

global void execute(Database.BatchableContext BC, List<Account> scope) 
    {   
        List<Account> accounts = [SELECT id, (SELECT outreach_status__c,Initial_Contact__c, Champion__c, Finance_DM__c, Operations_DM__c, Executive_Sponsor__c ,LastActivityDate FROM Contacts) FROM Account WHERE Id in :scope];
}

Or is it

List<Account> Scope = [SELECT id FROM ACCOUNT];
// This is the query being used

    global void execute(Database.BatchableContext BC, List<Account> scope) 
    {   
        List<Account> accounts = [SELECT id, (SELECT outreach_status__c,Initial_Contact__c, Champion__c, Finance_DM__c, Operations_DM__c, Executive_Sponsor__c ,LastActivityDate FROM Contacts) FROM Account WHERE Id = :scope];
}

Basically I am not sure if I should use "ID IN :Scope" or "ID = :Scope". I am asking this because I am finding that not all records are being processed.

3
  • Behavior between IN and = is the same for a collection.
    – Adrian Larson
    Feb 6, 2020 at 21:09
  • @AdrianLarson This is a list though. Does that make a difference? Feb 8, 2020 at 22:27
  • 1
    That is a type of collection...and matches what is in the question I flagged as a duplicate. You can use IN or = equally here, they're both valid.
    – Adrian Larson
    Feb 8, 2020 at 22:48

0

Browse other questions tagged .