Created
April 21, 2018 09:47
-
-
Save anilsomasundaran/ddc7d0d3ad61601ea1d703208afe9ef6 to your computer and use it in GitHub Desktop.
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
<aura:component abstract="true" extensible="true" access="global" > | |
{!v.body} | |
</aura: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
({ | |
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