4

I have created one Component from which I'm creating new record, using force:createRecord

The new record creation page is opening perfectly on click of Quick Action but one new blank model is also showing up on top of that page. I'm not able to figure out how to hide this popup.

The screenenter image description here of Popup:

Here is my code: Component:

<aura:component implements="force:lightningQuickAction" access="global" >
      <aura:handler name="init" value="{!this}" action="{!c.createRecord}"/>
</aura:component>

Controller:

   ({
       createRecord: function(component, event, helper) {
          var createRecordEvent = $A.get("e.force:createRecord");
          createRecordEvent.setParams({
             "entityApiName": "custom_obj__c",
              "defaultFieldValues": {
            'Name' : 'Abc'
            }
          });
          createRecordEvent.fire();
$A.get("e.force:closeQuickAction").fire();
       }
    })
5
  • 2
    Question, why don't you just create a new "Create Record" quick action? Is there more logic than what we can see? Oct 17, 2017 at 15:18
  • Basically I wanted to have a list view button from where I need to prepopulate some value Oct 17, 2017 at 15:41
  • Regular quick actions allow you to set default values for fields... Oct 17, 2017 at 15:45
  • but I won't be able to use Quick Action in list view button Oct 17, 2017 at 16:45
  • You should fire the closeQuickAction event before you fire the createRecordEvent.
    – Folkert
    Jul 30, 2019 at 14:21

4 Answers 4

5

Basically you need fire closeQuickAction event after createRecord event to close quick action window. Add below code after firing createRecord event.

    var dismissActionPanel = $A.get("e.force:closeQuickAction");
    dismissActionPanel.fire();
4
  • 1
    I already tried it. it is actually closing the new record creation model not the blank model, which is coming on top of the record creation model. Oct 18, 2017 at 8:21
  • Plz share your code
    – brahma
    Oct 19, 2017 at 9:52
  • I have modified my code. Oct 20, 2017 at 14:26
  • Same thing happened to me when using this code, the answer from Remy Chen and Raul Kasaundhan does work. My best guess firing the event closes the most recently opened quick action window. Using the timeout helps ensure that all windows are open before it fires.
    – gNerb
    May 31, 2023 at 14:55
2

please try the following codes.

window.setTimeout(
    $A.getCallback(function() {
        $A.get("e.force:closeQuickAction").fire();
    }), 1000
);
var createRecordEvent = $A.get("e.force:createRecord");
createRecordEvent.setParams({
    "entityApiName": "custom_obj__c",
    "defaultFieldValues": {
        'Name' : 'Abc'
    }
});
createRecordEvent.fire();

and let me know whether this works for you. Thanks.

5
  • It is automatically closing the blank model, but users can still see this blank model for some seconds Nov 20, 2017 at 6:39
  • Put the time from 1000 to 10 or something else. There is no way to eliminate the start up of blank. Or you can add spinner in the blank popup.
    – Remy Chen
    Nov 21, 2017 at 6:09
  • even giving time as 1, I can see that popup Nov 22, 2017 at 7:05
  • You might need to use spinner in the blank popup. You can't make it disappear at the beginning because your new creation is created from that Action. I believe the way you want to implement is impossible.
    – Remy Chen
    Nov 27, 2017 at 5:19
  • After testing, this is the only suggested approach that seems to work. The delay on setTimeout doesn't seem to matter (tested as low as 1/1000th second). For some reason 100/1000 seems to work the best for me.
    – gNerb
    May 31, 2023 at 16:33
0
  1. I think is not Working on direct using for Onload. It's work when you set the timeout On Load and call dismiss quick action it's Work.

    doinit : function(component, event, helper) {
    
        window.setTimeout(
            $A.getCallback(function() {
                $A.get("e.force:closeQuickAction").fire();
    
            }),100
        );
    
        var recordId = component.get("v.recordId");
        var newEvent = $A.get("e.force:navigateToComponent");
        newEvent.setParams({
            componentDef: "c:Navigate",
            componentAttributes: {
                sNavigateComVal1 :recordId
            }
        });
        newEvent.fire();
    }
    
2
  • 1
    Welcome to SFSE! Please take the tour, read How to Ask and How to Answer. Right now, this doesn't look like an answer to me, but rather a similar question. Please consider asking your own question (and linking back to this one, if it helps provide context), and gather up as much information and detail as you can.
    – Derek F
    Feb 6, 2019 at 12:24
  • @DerekF I don't think that's correct, this is the same answer another user provided and is functional, Maybe suggest some edits to the language to make it more clear but its not a bad answer.
    – gNerb
    May 31, 2023 at 14:52
-2

I posted a solution to this on the developer forums accessible via the link below, worked perfectly to hide the box, box wont appear at all. and there wont be backdrop also.

https://developer.salesforce.com/forums/?id=9060G000000MVx8QAG

<aura:component>
   <aura:html tag="style">
        .slds-modal {
        visibility: hidden;
        display: none;
        }
        .slds-backdrop{
        display: none;
        
        }        
  </aura:html>
  <aura:handler name="init" value="{! this }" action="{!c.doInit }"/>
</aura:component>

Aura Controller J:

 doInit: > function (component, event, helper) {
   $A.get("e.force:closeQuickAction").fire();
         
   var evt = $A.get("e.force:navigateToComponent");
   evt.setParams({
     componentDef : "c:methodName",
     componentAttributes: {
       recordId : component.get("v.recordId")
     }
   });
   evt.fire();
}
1
  • Tested, unfortunately this hides BOTH boxes. There doesn't seem to be any classes that are unique enough to hide only the desired box.
    – gNerb
    May 31, 2023 at 16:30

You must log in to answer this question.

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