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


7

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: "...


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.


4

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

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

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

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/...


4

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 ...


4

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.


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 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 ...


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.


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, ...


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

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 ...


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

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

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 ...


1

I created a simple custom ToastError component to get around this limitation. Usage <c:ToastError visible="{!v.showError}" contents="{!v.errorMessage}" /> Implementation: ToastError.cmp <aura:component> <aura:attribute name="visible" type="Boolean" default="false" /> <aura:attribute name="contents" type="String" /> &...


1

I think your issue is similar to this. Known Issue


1

You have a duration attribute in lightning toast method. Once the toast method is fired using. toastEvent.fire(); you can use javascript setTimeout method of the same duration and In that method, you can use javascript to set focus on particular input with particular id like this. document.getElementById("InputId").focus(); or you can use cmp.get("v.Input"...


1

You can accomplish this using jquery to change the css of the toast component. Add this line before your toast $('.forceToastManager').css('white-space', 'pre-wrap'); Then just add \n's wherever you want line breaks in your message. In your case you can replace . with \n and I believe it will work as you want.


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