I'm trying to create a query that returns the Account
's Id, Name, BillingState and Phone from an Opportunity however when I do so, I get either:
Illegal assignment from List to Account
Or
Illegal assignment from List to List
This is the Apex code that I'm using
public with sharing class MyController {
@AuraEnabled
public static Account getAccountFromOppotunity(Id opportunityId) {
Account acct = [SELECT Accountid, Account.Name, Account.BillingState, Account.Phone FROM Opportunity WHERE Id = :opportunityId];
return acct;
}
}
If I use the above code I get the first error message, and if I try to set it to a List <Account> accts = [...]
I get the 2nd one (changing return type as well)
How can I resolve this? This is my first time using Apex so I'm kinda lost and it looks fine according to the docs