function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mk2013mk2013 

SOQL in apex

Hi,

I am new to Salesforce and apex and trying to retrieve an existing account which I think should  be a very simple thing.

But I do not get any rows back. Same query runs fine when I run it in Eclipse IDE on the schema.

 What can be the reason for not getting any rows back in apex code?

 

    public static Account retrieveAccount(){
    	Account testAct;
        try{
           String aId = '001V000000E1CPyIAN';
           List<Account> actList = new List<Account>();
           actList  = [select Id, Name from Account where Id=: aId];
           if (!actList.isEmpty()) {
                testAct = actList.get(0);   //get existing act
            }
            System.debug('\n\n\n\n Acct = ' + testAct +'\n\n\n\n');
       }catch(QueryException ex){

           System.debug(ex.getMessage());
        }     
       return testAct;
    }

 Thanks,

mk2013

Puja_mfsiPuja_mfsi

Hi,

I think the hardcoded Id is not present in your org i.e. No account exist with this id in your organization .

Please check .

Please let me know if the issue is persist.

Yoganand GadekarYoganand Gadekar

definately, your harcoded id may not be present in your org hence it is not retriving any records.