You need to sign in to do that
Don't have an account?
Event being handled even when tab is not open
I have a custom tab that displays a lighning component which on a click event allows a user to edit a record.
I am trying to listen for a save success on the e.force:editRecord and after much searching I found no solution as apparently there is no standard callback for the editRecord
https://trailblazer.salesforce.com/ideaView?id=0873A000000CQQiQAO
As per a few other suggestions I have added an handler for the force:showToast
This is working, albeit a hack, but the problem is as this is an application event it is constantly being listened for even if the custom tab isn't open.
Does anyone have any ideas how I can remedy this
Many thanks,
I am trying to listen for a save success on the e.force:editRecord and after much searching I found no solution as apparently there is no standard callback for the editRecord
https://trailblazer.salesforce.com/ideaView?id=0873A000000CQQiQAO
As per a few other suggestions I have added an handler for the force:showToast
This is working, albeit a hack, but the problem is as this is an application event it is constantly being listened for even if the custom tab isn't open.
Does anyone have any ideas how I can remedy this
<aura:handler event="force:showToast" action="{!c.handleToastEvent}"/> handleToastEvent: function(component, event, helper){ var toastMessageParams = event.getParams(); var message = toastMessageParams.message; if(message.includes('Resource Placeholder') && message.includes('was saved')){ var calendar = component.get('v._Calendar'); var calendarEvent = event.getParam("calendarEvent") helper.fetchCalendarEvents(component, calendar, calendarEvent); } }
Many thanks,
I would suggest adding an attribute isTabOpen to check the activate tab, then add <aura:if> to the handler to stop listening to the event if the tab is not open.
<aura:if isTrue="{!v.isTabOpen}">
<aura:handler event="force:showToast" action="{!c.handleToastEvent}"/>
</aura:if>
Thank you for the suggestion. I can't wrap the event in an Aura:if though as i get an error of 'invalid attribute "event"
My code is below, I can't spot any syntax mistakes, but apologies if I've missed something