Last active
February 25, 2019 18:47
-
-
Save maujood/00bbc07566755c1b5a1569e7321dd036 to your computer and use it in GitHub Desktop.
Using the ApexHelper component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//You can use these utility methods by extending from the ApexHelper component created earlier: | |
//<aura:component extends="c:ApexHelper"> | |
//Example of executing an Apex Method through our new utility: | |
helper.apex(component, "search", { searchstr : searchTerm }) | |
.then(function (result) { | |
//do something with the result | |
}) | |
.catch(function (error) { | |
//do something about the error | |
}) | |
//Example of executing SOQL with our new utility | |
helper.soql(component, "SELECT Id, Name, AnnualRevenue, Industry FROM Account WHERE Name LIKE '%" + searchTerm + "%'") | |
.then(function (accounts) { | |
//do something about the accounts | |
}) | |
.catch(function (error) { | |
//do something about the error | |
}) | |
//Remember to use `this` instead of `helper` if you're using the utility methods inside a helper method. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refer to article on medium for details: https://medium.com/salesforce-zolo/call-apex-or-soql-with-just-one-line-of-code-from-your-lightning-aura-components-3b4b4fe70417