You need to sign in to do that
Don't have an account?
How to use a showToast as a notification alert that will pop up when the timer hits a specific time?
Hi everyone
Below is my code for showToast but it invokes on doinit(). The problem is I have to reload the page to see the Toast as a notification. Is there a way to fire the toastEvent automatically on a specific time.
doInit : function(component, event, helper) {
var action = component.get("c.getAlertDateTime");
action.setCallback(this, function(response){
var state = response.getState();
if(state === "SUCCESS"){
var result = response.getReturnValue();
var date = new Date();
var Today = date.toISOString();
for(var i=0; i!=result.length; i++){
if(result[i].pshak__Alert_Date_Time__c <= Today){
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
title : 'Note Reminder',
message: 'Check out your note \''+result[i].Name+'\'',
type: 'warning',
mode: 'sticky',
});
toastEvent.fire();
}
}
component.set("v.notesList", result);
}
});
$A.enqueueAction(action);
}
Thanks.
Below is my code for showToast but it invokes on doinit(). The problem is I have to reload the page to see the Toast as a notification. Is there a way to fire the toastEvent automatically on a specific time.
doInit : function(component, event, helper) {
var action = component.get("c.getAlertDateTime");
action.setCallback(this, function(response){
var state = response.getState();
if(state === "SUCCESS"){
var result = response.getReturnValue();
var date = new Date();
var Today = date.toISOString();
for(var i=0; i!=result.length; i++){
if(result[i].pshak__Alert_Date_Time__c <= Today){
var toastEvent = $A.get("e.force:showToast");
toastEvent.setParams({
title : 'Note Reminder',
message: 'Check out your note \''+result[i].Name+'\'',
type: 'warning',
mode: 'sticky',
});
toastEvent.fire();
}
}
component.set("v.notesList", result);
}
});
$A.enqueueAction(action);
}
Thanks.
The following code will show toast in every minute
Following code for showing toast only once after the page has been load after 10 seconds
Dear Reader, Please mark as the best answer
Thanks & Regards,
Divya