Original code was
Set<Id> crConIds = new Set<Id>(); if (!crConIds.isEmpty()){ crConIds = new Map<Id, Account>( [SELECT Id, Name, ContactInfo__c FROM Account WHERE Id IN :crConIds]); } Modified Code to move query to own method.
if (!crConIds.isEmpty()){ Map<Id, Account> account_m = getAccountFromAccountId(); } public static Map<Id, Account> getAccountFromAccountId(){ String acctQuery = 'SELECT Id, Name, ContactInfo__c FROM Account WHERE Id IN :crConIds' Map<Id, Account> accts= new Map<Id, Account>((List<Account>)Database.query(acctQuery)); return accts; Test Class method that was previously passing now fails
Account acct= new Account( Name = 'Test Account' ); insert acct; Change_order__c cr = new Change_order__c( Name = 'Test CR', Type__c = 'Bug', Account = acct.id ) Error:
unexpected token: Id Class.ChangeOrderTriggerHandler.getAccountFromAccountId: references this line of code `Map<Id, Account> accts= new Map<Id, Account>((List<Account>)Database.query(acctQuery));` Class.ChangeOrderTriggerHandler.bulkBefore : references this line of code Map<Id, Account> account_m = getAccountFromAccountId(); Questions
- Is the updated class logic correct? The way I am referencing the new method?
- Is the issue caused by using Database.query?
- Do I need to update the Test method dues to the query being moved to its own method?