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
Arvind BalijepalliArvind Balijepalli 

why isnt this code isnt printing whats there in system.debug

i am running below indeveloper console and it doesnt print system.debug ? i suspect something wrong with the way list is retrieved ? pls let me know 


list<list<Sobject>> results = [find '4155557000' in PHONE FIELDS RETURNING contact(Phone, FirstName, LastName),
                                Account(Id, Phone, Name)];


list<Sobject> results1=results[0];

for(Sobject r : results1)
{
    if(r.getSobjectType()==Account.sObjectType)
    {
   account acc = (account)r;
    
    system.debug('value is '  + acc.Name);
    }
    
}
Best Answer chosen by Arvind Balijepalli
Mahesh DMahesh D
Hi Arvind,

Here is the code:

results[0[ will return list of Contacts
results[1] will return list of Accounts.
list<list<Sobject>> results = [find '4155557000' in PHONE FIELDS RETURNING contact(Phone, FirstName, LastName),
                                Account(Id, Phone, Name)];
list<Sobject> results1=results[1];

for(Sobject r : results1)
{
    if(r.getSobjectType()==Account.sObjectType)
    {
   account acc = (account)r;
    
    system.debug('value is '  + acc.Name);
    }
    
}
Please do let me know if it helps you.

Regards,
Mahesh

 

All Answers

Mahesh DMahesh D
Hi Arvind,

Here is the code:

results[0[ will return list of Contacts
results[1] will return list of Accounts.
list<list<Sobject>> results = [find '4155557000' in PHONE FIELDS RETURNING contact(Phone, FirstName, LastName),
                                Account(Id, Phone, Name)];
list<Sobject> results1=results[1];

for(Sobject r : results1)
{
    if(r.getSobjectType()==Account.sObjectType)
    {
   account acc = (account)r;
    
    system.debug('value is '  + acc.Name);
    }
    
}
Please do let me know if it helps you.

Regards,
Mahesh

 
This was selected as the best answer
Arvind BalijepalliArvind Balijepalli
oops ya , thanks Mahesh, that helped.