So I've got a project that uses a screen flow to update opportunities with a related payment record. Once the record is linked to the opp, I have a lightning component that displays summary data of the newly linked record. When the opp goes from a state of no payment record --> a state where there is a new payment record, I want to show a toast message that says "Successfully linked payment"

Problem Currently, it is showing the success message every time the opp loads or changes. This is expected because the wire method reloads everything when the record it's connected to changes. However, is there a way to make sure that the toast message only shows in the following scenarios.

Essentially I want to determine of the related record has been added and if it is valid, show the toast message, but not do this every time someone visits the opp record.


import { LightningElement, api, track, wire } from 'lwc';
import { refreshApex } from '@salesforce/apex';
import {getRecord} from 'lightning/uiRecordApi';
import { NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

//THESE have been imported with the '@salesforce/schema/OBJECTNAME.FIELDNAME syntax.
const FIELDS = [

@api recordId; //opp Id
    @api objectApiName;
    @api paymentRecordId;
    wiredOppResult; //stores the wired result and allows the refreshApex() to work correctly
    @track record;
    @track error;
    @track objectInfo;

@wire(getRecord, {recordId: '$recordId', fields: FIELDS})

        this.wiredOppResult = result;
        let data = result.data;
        let error = result.error;
        if(this.firstRun == false){
            this.firstRun = true;




        if(status == 'Valid'){
            //removing the this.showToast condition here makes the success message happen every time the record is loaded or changed. Which creates a notification fatigue. 
            if(this.showToast === true){
                this.MyShowToast('LINKED PAYMENT', 'Payment Method is valid and linked', 'Success');

  • 1
    Can you post any relevant code, such as the wire method you are using, any related apex, any methods showing how you're launching your toast message? – Ronnie Apr 9 at 20:37
  • 1
    Will do Ronnie. – thinker Apr 10 at 12:53
  • so is by chance 'Valid' set as a default option? – Ronnie Apr 10 at 16:55

You can have the Flow show the toast message instead of your lightning component.

| improve this answer | |
  • This I think is a good last option. But would like to be able to use LWC if possible to keep it all contained in the same code. – thinker Apr 10 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.