Carry out the following steps to develop an Apex Controller, which is used as part of the account search mechanism, using the Salesforce Developer Console:
- Click on the Setup gear icon, as shown in the following screenshot:
The Setup gear icon is located in the top right-hand area of the main home page.
- Click the Developer Console option, as shown in the following screenshot:
- In the resulting Developer Console window, click on File.
- Click on New.
- Click on Apex Class, as shown in the following screenshot:
- In the resulting New Apex class dialog, enter AccountSearchController in the Please enter a name for your new Apex class textbox.
- Click on OK, as shown in the following screenshot:
- In the resulting Apex class edit page, paste the following code:
public without sharing class AccountSearchController { @AuraEnabled public static List<Account> getAccounts(String psSearchText
{ String sSearchName = '%' + psSearchText + '%'; List<Account> accounts = [ SELECT Id, Name, Type, Industry, Description, Phone FROM Account WHERE Name LIKE :sSearchName ]; return accounts; } }
- Click on File.
- Click on Save, as shown in the following screenshot: