I created and displayed a custom list button in standard Lead list view. This references a Visualforce page. Clicking this button makes an action, and there's nothing wrong with the results in the backend so far.
My problem is that upon success of the operation, a toast that will supposedly display a success message is not displaying at all. The alert message is displaying, though. But upon dismissing this alert box, following error appears:
Error in $A.getCallback() [Cannot read property 'setParams' of undefined] Callback failed
Meanwhile, below are the current codes I have:
lead.app
<aura:application access="GLOBAL" extends="ltng:outApp" >
<c:lead />
</aura:application>
lead.cmp
<aura:component controller="MyClass" implements="force:lightningQuickAction">
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
</aura:component>
lead.js
({
"doInit" : function(cmp) {
var action = cmp.get("c.runClass");
action.setCallback(this, function(response) {
var state = response.getState();
var title = '';
var type = '';
var message = '';
if (state === "SUCCESS") {
alert("Success from server: " + response.getReturnValue());
title = 'Success';
type = 'success';
message = 'Operation is successful';
}
else if (state === "INCOMPLETE") {
// do something
}
else if (state === "ERROR") {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
console.log("Error message: " +
errors[0].message);
alert("Error from server:" + errors[0].message);
}
} else {
console.log("Unknown error");
}
}
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
"title": title,
"type": type,
"message": message
});
toastEvent.fire();
});
$A.enqueueAction(action);
}
})
Hoping anyone can lead me to the right direction.