Skip to content

Instantly share code, notes, and snippets.

@tommyilpazzo
Last active August 26, 2016 14:33
Show Gist options
  • Save tommyilpazzo/76b74481007b8b6db9585d757748f549 to your computer and use it in GitHub Desktop.
Save tommyilpazzo/76b74481007b8b6db9585d757748f549 to your computer and use it in GitHub Desktop.
SFDC: Lightning JS function to get objects from salesforce
// 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