How to do it...

Carry out the following steps to develop a Lightning JavaScript Helper which is used for searching accounts, using the Salesforce Developer Console:

  1. 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.

  1. Click the Developer Console option, as shown in the following screenshot:
  1. In the resulting Developer Console window, open the resource or click on the tab for the Lightning Component accountSearchBeforeCreate.cmp.
  2. Click on HELPER (or press Ctrl + Shift + 3), as shown in the following screenshot:
  1. In the resulting Lightning JavaScript Helper edit page, paste the following code:
({ SearchHelper: function(component, event) { 
   var action = component.get("c.getAccounts"); 
   action.setParams({'psSearchText':
component.get("v.searchString") }); action.setCallback(this, function(response) { var state = response.getState(); if (state === "SUCCESS") { var returnValue = response.getReturnValue(); // if nothing is returned allow user to create an
account. if (returnValue.length == 0) { component.set("v.createStatus", true); }
else { component.set("v.createStatus", false); } // Set the Component attributes component.set("v.searchCounts",
returnValue.length); component.set("v.searchResult", returnValue); } }); $A.enqueueAction(action); }, })
  1. Click on File.
  2. Click on Save, as shown in the following screenshot:
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset