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
Rakesh MRakesh M 

Initial term of field expression must be a concrete SObject: List<Account>

Hi,

As I want to know count and full name of the searched key.  So I have written the below mentioned code.

But this code shows count properly not full name of the data.  Request you to help me.

list<list<Sobject>> Soslquery = [find 'rakesh*' in all fields returning account(name), f_97__c(name_1__c), contact(firstname)];
// Store the result set into the associated 

list<account> acc= ((list<account>) soslquery[0]);
system.debug('Count of searched word in account object are: '+acc.size());
list<f_97__c> f = ((list<f_97__c>) soslquery[1]);
system.debug('Count of searched word in f.97 object are: '+f.size());
list<contact> con=((list<contact>) soslquery[2]);
system.debug('Count of searched word in contact object are: '+con.size());

if(acc.size()>0)
{
    system.debug('Count of searched word in account object are: '+acc.size());
    for(account e:acc)
     {
     system.debug('Account name is:'+acc.name);
     }
}

if(f.size()>0)
{
    system.debug('Count of searched word in f.97 object are: '+f.size());
    for(f_97__c g:f)
    {
        system.debug('f_97__c name is: '+g.name_1__c);
    }
}

if(con.size()>0)
{
    system.debug('Count of searched word in contact object are: '+con.size());
     for(contact h:con)
     {
     system.debug('Contact name is : '+con.firstname);
     }
}
Abhishek_DEOAbhishek_DEO
Proble is with the code that you put in debug statement. for eg.

if(acc.size()>0)
{
    system.debug('Count of searched word in account object are: '+acc.size());
    for(account e:acc)
     {
     system.debug('Account name is:'+acc.name);
     }
}

Here "acc" is a list and list is a kind of array.so to access an element/field, you have to use

for(account e:acc)
     {
     system.debug('Account name is:'+e.name); // here e is teh actual object in your list
     }

belwo code should work
 
if(acc.size()>0)
{
    system.debug('Count of searched word in account object are: '+acc.size());
    for(account e:acc)
     {
     system.debug('Account name is:'+e.name);
     }
}

if(f.size()>0)
{
    system.debug('Count of searched word in f.97 object are: '+f.size());
    for(f_97__c g:f)
    {
        system.debug('f_97__c name is: '+g.name_1__c);
    }
}

if(con.size()>0)
{
    system.debug('Count of searched word in contact object are: '+con.size());
     for(contact h:con)
     {
     system.debug('Contact name is : '+h.firstname);
     }
}

Let me know if it helps
Rakesh MRakesh M
Thanks.
Abhishek_DEOAbhishek_DEO
Hi Rakesh,

If given answer helped you then you can mark this as resolved else let me know if there is any concern.