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
krishnanpradipkrishnanpradip 

Help in loading account into a list

I have a string

|      859706 | Conficker infected host at 192.168.155.60
   |        5744 |       7089 |        5 |                 4 | 1309714576 |
                    1 | completed           | 

 i am splitting it using the following code

     columns=parts[i].split('\\|');
     System.debug('columns size++++++++++++  '+columns.size());
     List<Account> ac = [select id, name from account where accountid__c=:columns[3]];
     System.debug('account No+++++     '+columns[3] );

 I am also searching in account object  where  a custom field accountid__c is equal to columns[3]

But for some reason the result is always 0. I checked in account it does have a record matching. This is the query used from apex explorer.

 

select id, name,accountid__c from account where accountid__c ='5744'

00190000007NtKDAA0	account1	5744

 

Here is the debug log to prove i am pulling the correct value.

 

02:26:30.349 (349794000)|USER_DEBUG|[28]|DEBUG|columns size++++++++++++  11
02:26:30.349 (349831000)|SYSTEM_METHOD_EXIT|[28]|System.debug(ANY)
02:26:30.350 (350097000)|SOQL_EXECUTE_BEGIN|[29]|Aggregations:0|select id, name from account where accountid__c=:columns[3]
02:26:30.372 (372988000)|SOQL_EXECUTE_END|[29]|Rows:0
02:26:30.373 (373310000)|SYSTEM_METHOD_ENTRY|[30]|System.debug(ANY)
02:26:30.373 (373393000)|USER_DEBUG|[30]|DEBUG|account No+++++             5744 

 Thanks

CLKCLK

try this

 

List<Account> ac = [select id, name from account where accountid__c=:columns[2]];