Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@anilsomasundaran
Created April 21, 2018 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anilsomasundaran/ddc7d0d3ad61601ea1d703208afe9ef6 to your computer and use it in GitHub Desktop.
Save anilsomasundaran/ddc7d0d3ad61601ea1d703208afe9ef6 to your computer and use it in GitHub Desktop.
<aura:component abstract="true" extensible="true" access="global" >
{!v.body}
</aura:component>
({
runServerMethod : function (component, serverMethodName, successCallBack, failureCallback, params ) {
var self = this;
var action = component.get(serverMethodName);
if (params) {
action.setParams(params);
}
action.setCallback( this, function (response) {
var state = response.getState();
if (state === "SUCCESS") {
successCallBack.call(this,response);
} else if (state === "INCOMPLETE") {
// show a toast or create a callback to control this state as well.
console.log("Failed to connect Salesforce!!");
}else if (state === "ERROR") {
var errors = response.getError();
if (!errors) {
errors = [{"message" : "Unknown Error Occured"}];
}
failureCallback.call(this,errors);
}
});
$A.enqueueAction(action);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment