You need to sign in to do that
Don't have an account?
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);
}
}
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);
}
}
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
Let me know if it helps
If given answer helped you then you can mark this as resolved else let me know if there is any concern.