0

I want to close quick action after e.force:editRecord event, I tried without e.force:editRecord event but in that case also quick action is not closing, I tried with setInterval function with delay 1s, this also not works for me. Any advice

({
  doInit: function(component, event, helper) {
    if ($A.get("$Browser.isPhone")) {
      component.set("v.isMobileorTablet", true);
    } else if ($A.get("$Browser.isTablet")) {
      component.set("v.isMobileorTablet", true);
    } else {
      var editRecordEvent = $A.get("e.force:editRecord");
      editRecordEvent.setParams({
        recordId: component.get("v.recordId")
      });

      editRecordEvent.fire();
      $A.get("e.force:closeQuickAction").fire();
    }
  }
});
3
  • are you sure that your code doesn't fail before the $A.get("e.force:closeQuickAction").fire(); line?
    – Novarg
    Commented Oct 31, 2019 at 14:39
  • code is running fine
    – Sarvesh
    Commented Oct 31, 2019 at 15:12
  • which quick action are you trying to close? Commented Oct 31, 2019 at 17:30

1 Answer 1

1

doinit is for initialization where the dom and listeners are not ready

({
  doInit: function(component, event, helper) {
    if ($A.get("$Browser.isPhone")) {
      component.set("v.isMobileorTablet", true);
    } else if ($A.get("$Browser.isTablet")) {
      component.set("v.isMobileorTablet", true);
    } else {
      var editRecordEvent = $A.get("e.force:editRecord");
      editRecordEvent.setParams({
        recordId: component.get("v.recordId")
      });
      var action = component.get('c.closeAction');
       //or
       //var action = component.get('c.anotherOption'); 
      $A.enqueueAction(action);
      editRecordEvent.fire();

    }
  },
 closeAction :function(component, event, helper){
    $A.get("e.force:closeQuickAction").fire();
 },
 anotherOption : function(){
   setTimeout(()=>{
       let quickActionClose = $A.get("e.force:closeQuickAction");
       quickActionClose.fire();
    },1000);
 }
});
3
  • Ahh! option 1 works for me thanks!
    – Sarvesh
    Commented Nov 2, 2019 at 13:25
  • I am calling multiple helper methods in doInit(which are having server apex calls) and again in helper methods i am making server apex calls so where should my closequickaction be placed, please help me tried many things even this approach but nothing is working out. Commented Sep 25, 2020 at 8:47
  • Please log another question whiteout seeing code it is not possible to answer. You should not do multiple server call from doinit use wrapper to get the data at once. Commented Oct 5, 2020 at 1:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .