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 v2

Hehy, 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
There should be a search for the total closed Amount of all Accounts

Help me please!
thanks.
 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi ,

You may need an another input field on the screen for amount and take the parameter same as Name and query it based on the Amount as well in the inner query.


If this solution helps, Please mark it as best answer.

Thanks,