Last active
August 26, 2016 14:33
-
-
Save tommyilpazzo/76b74481007b8b6db9585d757748f549 to your computer and use it in GitHub Desktop.
SFDC: Lightning JS function to get objects from salesforce
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
// Load objects from Salesforce | |
getObjects: function(component, event, helper) { | |
// Create the action | |
var action = component.get("c.getObjects"); | |
// Add callback behavior for when response is received | |
action.setCallback(this, function(response) { | |
var state = response.getState(); | |
if (component.isValid() && state === "SUCCESS") { | |
component.set("v.objects", response.getReturnValue()); | |
} else { | |
console.log("Failed with state: " + state); | |
} | |
}); | |
// Send action off to be executed | |
$A.enqueueAction(action); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment