I am trying to show the toast on the screen after the field is updated using the lightning component the Controller looks like below


  recordLoaded: function(component, event, helper) {
    var caseRecord = component.get("v.record"),
      recordData = component.find("recordData");

      caseRecord.Status = 'Closed';

      if(!component.get("v.complete")) { // Avoid infinite loop
      component.set("v.complete", true);
      component.set("v.record", caseRecord);
      recordData.saveRecord($A.getCallback(function(result) {
        if(result.state === "SUCCESS" || result.state === "DRAFT") {


            var toastEvent = $A.get("e.force:showToast");
                title: "Success!",
                message: "Congrats, it works!",
                type: "success"

        } else { /* show an error here */ }



<aura:component implements="force:hasRecordId,force:lightningQuickActionWithoutHeader">
  <aura:attribute name="record" type="Case" default="{ 'sobjectType': 'Case' }" />
  <aura:attribute name="complete" type="Boolean" default="false" />
  <force:recordData recordId="{!v.recordId}"
                    recordUpdated="{!c.recordLoaded}" />

Everything else is working but I cannot see the Toast on the screen after it updated the field

  • try after removing $A.get("e.force:refreshView").fire(); – User6670 Apr 2 at 19:25
  • Awesome that worked. Can we call the lightning component from the button as a URL? – user81642 Apr 2 at 20:12

Try removing


and then fire toast and no i dont think you can launch component from button though you can open visual force page from button where you can call your component from there here is the documentation on how you can do that https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/components_visualforce.htm

| improve this answer | |

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.