• sampathawaduge sameera
  • NEWBIE
  • 40 Points
  • Member since 2018
  • Engineer - Technology
  • Virtusa

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 3
    Replies
Hi,

I am trying to update contact's phone by querying the account , But it gives me following error

"A non foreign key field cannot be referenced in a path expression: Contacts"

try
{
    Account a=[select name,(select name from contacts ) from account];
    a.name='Dialog';
    a.contacts.phone=123;
    
    update a;
    update a.Contacts;
}
catch(DmlException e)
{
    System.debug(e.getMessage());
}
Why do we need to store SOSL result in List<List<sObject>> ?
what is the advantages of querying data withing the for loop itself like below

for(Account a:[select name from Account])
{
***logic***
}
When generating execel sheet table structure is not in the execel sheet it's only a plain sheet without table structure.Even it displays data it shows and error saying "not maching" when opening. Provide me with the complete answer.

Thank you.