Hello I am trying to make a Lightning component common to Community and SF1 . This component has been added as quick action on one of the object detail page.
Now when i am using the toast event, it gives me error as
Something has gone wrong. [TypeError: Cannot read property 'setParams' of undefined] . Please try again.
Code for same -
action.setCallback(this, function(response) {
var state = response.getState();
console.log('state--->1', state);
if (state === 'SUCCESS') {
jobApplicantId = response.getReturnValue();
fromPos = toPos;
console.log('fileContents.length -->', fileContents.length);
toPos = Math.min(fileContents.length, fromPos + CHUNK_SIZE);
console.log('fromPos -->' , fromPos);
console.log('toPos -->' , toPos);
if (fromPos < toPos) {
this.uploadChunk(component, file, fileContents, fromPos, toPos, attachId);
} else if (fromPos == toPos) {
//alert('Job Application Successful');
var toastEvent = $A.get("e.force:showToast");
console.log('toastEvent -->', toastEvent);
toastEvent.setParams({
"title": "Success!",
"message": "The record has been updated successfully."
});
toastEvent.fire();
component.find("comments").set("v.value", "");
component.find("file").getElement().value = "";
this.displayJobAppliedButton(component);
//component.find("file").getElement().removeAttribute('value');
}
} else {
var errors = response.getError();
if (errors) {
if (errors[0] && errors[0].message) {
alert("Error message: " +
errors[0].message);
}
} else {
console.log("Unknown error");
}
}
});
Snapshot - This whole thing is in a helper class? can this be the issue?