You need to sign in to do that
Don't have an account?
Benedict Yeo 6
Cannot get result from search
Hi, I've a problem with the following code.. I can get the o.AccountId correctly, but whenever I run the SOQL query, the result returned in an empty set.. What am I doing wrong?
public class prefillFields { public static void applyAddress(Order o) { System.debug('o.AccountId: ' + o.AccountId); String accountId = o.AccountId; List<Account> accounts = Database.query('SELECT id, Name, BillingCity, Department_NS__c, ReportingCountry_NS__c FROM Account WHERE Id = :accountId'); //[SELECT id, Name, BillingCity, Department_NS__c, ReportingCountry_NS__c FROM Account]; // WHERE Id = :o.AccountId]; if(accounts.size() > 0) { System.debug('Gotten address..?'); System.debug('ID: ' + accounts[0].id); System.debug('City: ' + accounts[0].billingCity); for (Account a : accounts) { String accountName = a.Name; String billingCity = a.BillingCity; System.Debug('Billing City: ' + billingCity); } } else { System.debug('List is empty!'); } } }
Do you have read access to that particular record?? (Assuming you have read access @ object level), to verify try adding without sharing clause to your class declaration and see if it works
Thanks,
balaji