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
IndianajonesIndianajones 

Help please with soql and search

Hey, i create lightning-accordion with account name. in my tabs i have opportunity with amount. I have search with Account name. I need search with Account name and Amount of Opportunity. I have Soql for Account Name:
 
public class OpportunityController {
    @AuraEnabled(cacheable=true)
    public static List<Account> getAcc( String searchKey) {
        string searchKeyword = '%' + searchKey + '%';
           list<Account> accountListRecord = new list<Account>();
        for(Account accObj : [SELECT Id, Name,(select id,Name,Amount,CreatedDate,CloseDate, AccountId from opportunities where StageName = 'Closed Won') FROM Account
                            WHERE name LIKE : searchKeyword]){
           accountListRecord.add(accObj);
                            }
         if(accountListRecord.size() == 0){
            throw new AuraHandledException('No Record Found..'); 
         }
      return accountListRecord;
    }    
}
How i can update my code for search account name + opportunity amount?

How its look:
User-added image

screen 2.

User-added image

thanks.


 
PriyaPriya (Salesforce Developers) 
Hey Bogdan,

Do you want to search the opportunity based on the amount from any specific Account(only from 1 account) or in general?

Thanks!
IndianajonesIndianajones
Hey Priya,

There should be a search for the total closed Amount of all Accounts

Thanks!