Hot answers tagged

9

Not an immediate answer, but the long term solution would be to indicate the known issue affects you Lightning Component force:showToast event displays toast message behind action window in Lightning Experience and Salesforce1


8

You can provide an 'action' in the messageTemplateData provided to the showToast event. Here's an example where the link's action becomes creating an event which will trigger a second toast. showToast: function(component, event, helper) { var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ title: "Success!", mode: "...


6

Yes, you can get the toast information, as it is an application event, and thus propagates to all interested listeners. Here's the code I wrote that demonstrates this: <aura:component implements="flexipage:availableForAllPageTypes"> Toast Processor <aura:handler name="init" value="{!this}" action="{!c.init}" /> <aura:handler ...


5

You can use the lightning:notificationsLibrary and put a notice up over your modal. It's not the same as a toast, but might work in some cases.


5

As of today, it doesn't seem you can use links in toast message in LWC directly. I have created this idea to allow the ability to show links in LWC toasts. In Lighting Aura Components (LAC), the force:showToast had additional attributes for this purpose - messageTemplate and messageTemplateData. But, these attributes are not available for the ...


5

Okay looks like documentation is a bit messed. This is what I found by trying all pester - Stays for 3 seconds, No close symbol sticky - Stays infinitely or Until you press the close button dismissable - Stays for 3 seconds, you can close it by pressing close button.


5

var resultsToast = $A.get("e.force:showToast"); resultsToast.setParams({ mode: 'sticky', message: 'This is a required message', messageTemplate: 'Record {0} created! See it {1}!', messageTemplateData: ['Salesforce', { **url: 'https://xx-dev-ed....


4

You can't. There's no API available for a developer to alter a toast once it has been dispatched, including closing the toast or altering its behavior. You have three basic options here: show the toast until a duration has elapsed, show the toast until the user dismisses it, or show the toast until the duration has elapsed or the user dismisses it, whichever ...


4

As far as I can tell, you have to literally use templating to get them to appear correctly: ({ init: function(component, event, helper) { $A.get("e.force:showToast") .setParams({title:"Success", message:"hello world", messageTemplate:"{0}hello world{1}", messageTemplateData: ["{...


4

From Salesforce docs: e.force:showToast event is handled by the one.app container. It’s supported in Lightning Experience, Salesforce app, and Lightning communities. It doesn't say anything about classic or VF, so my best guess is You have to manually implement toast using SLDS. Src: https://developer.salesforce.com/docs/component-library/bundle/...


3

From the description and image ,I see that you are using Lightning components inside the Visualforce page . Having lightning components inside the visualforce ,you will loose certain events as documented in the guide .The events that are not supported are as below 1.force:createRecord 2.force:editRecord 3.force:navigateToList 4.force:navigateToObjectHome ...


3

As you can see here platformShoToastEvent can only be used in Lightning Experience explicitly. Since standard toasts are based on Appliacation Events there is nothing to handle your event in Lightning OutApp. So what usually happens with toast events? You dispatch an event which is most probably set to propagate outside shadow DOM boundary (see ...


3

With @wire, you can provide a method instead: @track accounts = []; @wire(loadAccounts) wireAccountLoaded({data, error}) { if(data) { this.accounts = data; } else { this.toastError(error, 'Errors'); } } This is demonstrated in the documentation.


3

Taake a look at the changes I've made here: https://developer.salesforce.com/docs/component-library/tools/playground/c_TB0R6b/13/edit I've removed the slds-is-relative class on line 3 of toast.html, and added a few rules to toast.css. Cheers!


3

You could use slds-toast Then you can use setTimeout() to make the custom toast disappear after a few seconds handleClick(){ let delay = 1000 setTimeout(() => { this.visible = false; }, delay ); } <template if:true={visible}> <div style="position:absolute;top:1rem;left:1rem;right:1rem">...


2

The short answer to this is "no, you cannot trigger a toast from Apex". This is because Apex is a server-side language and toasts must be launched from the front-end. However, as @glls answer says, you can make a call to Apex, interpret its result, and then trigger a toast based on what results are. This is a very common pattern with errors, for example, ...


2

added You get error message ONLY when this is undefined - not when this is re-scoped to different object. For your toast to work correctly this should refer to class HoldModal as toast should be invoked on instance of the class and not on any other element. Although you are trying to save the scope of this by using const thisReference = this;, the scope of ...


2

Have a read of this article on SFDC Monkey that covers this exact issue! (I've used this and it works great) http://sfdcmonkey.com/2018/05/05/multiline-toast-message-lightning-component/


2

The ShowToastEvent is handled by the Lightning Experience. When you're not in the Lightning Experience, this event will not be handled, and have no effect. This includes usage in Visualforce, Classic, Communities, etc. You'll want to build your own custom toast component if you need to show toasts outside of the Lightning Experience. When using any component,...


2

You can make use of ui:message component which will work in lightning out. The only thing is UI components have been deprecated but it would be a quick win. Or, You have to use slds -Toast in your lightning component so that it will work in visualforce page as well. check out this:- Display and close toast in SLDS


1

You might be able to simply listen to the toast event like you listen to any other event and chain your actions. <aura:handler event="force:showToast" action="{!c.handleApplicationEvent}"/>


1

Turns out that the doCloseModal() function was closing the modal before the doDisplayToastMsg() function inside the fetch() was getting a chance to run. The doDisplayToastMsg() after the fetch() was displaying the toast correctly because it ran before the fetch() completed. Solution was to move the doCloseModal() to inside the fetch(), after the ...


1

You should implement proper error handling in apex using AuraHandledException. Apex code should always be bulkified - you should return list or map. And process it in javascript accordingly - you can use 1st record if needed. Javascript is case-sensitive. Its true. (not True or 'True') No problem if you want to implement fine-tuned exceptions like ...


1

When you wire a class field/property, you can handle error only in HTML. You cannot handle error in Javascript (to show toast) by using class property. JS: @wire(getAccounts) accounts = []; //class field/property HTML: <template if:true={accounts.error} <c-error-panel errors={accounts.error}></...


1

Normally, toasts are something that you do on the client, yes, you can trigger it with apex, you just need to have the apex class be invoked from the client and return a response that can be handled by your client side controller in order to trigger a toast you will have to use an @AuraEnabled decorator on your apex method and handle the response ...


1

No, a toast is an informative message (e.g. an error occurred or something else). It is not a modal dialog with buttons you can configure. You'll notice that there's absolutely no way to know that a toast has even been closed/dismissed, much less know the disposition of that closure. The correct method would be to use the lightning:overlayLibrary (or create ...


1

Are you firing this from the developer console? if that is the case try to do it via an app or lightning quick action. I think that your toastEvent is undefined because you are trying to fire it from the Developer Console. – the solution for this is to fire this component from a app or lightning quick action. You can also drag it to a detail page and verify ...


1

Use e.force:showToast to show toast https://developer.salesforce.com/docs/component-library/bundle/force:showToast/documentation showToast : function(component, event, helper) { var toastEvent = $A.get("e.force:showToast"); toastEvent.setParams({ "title": "Success!", "message": "The record has been updated successfully." }); ...


1

You can use below code to show Toast Message in VF Page. <apex:page > <apex:slds /> <script> function toastLaunch(){ var element = document.getElementById("ToastMessage"); element.classList.toggle("slds-hidden"); } </script> <div class="demo-only slds-hidden" style="height: 4rem;" id='ToastMessage'> <div class="...


1

In your setCallback In your JS controller, use below: samplecall.setCallback(this, function(Callresp) { if (Callresp.getState() === "SUCCESS") { helper.showToast('success', Callresp.getReturnValue() ); } else if (status === "INCOMPLETE") { helper.showToast('error', Callresp.getReturnValue() ); } else ...


Only top voted, non community-wiki answers of a minimum length are eligible