1

Need to initiate force:create record from lightning quick action: 1. Output is not as expected two modals are showing up. I need only new contact modal. How to achieve this? Please help.. Thanks 2. How to Pre-populate account name in the create contact form in modal popup.

Quick action created as below

Created a lightning component: CreateRec.cmp:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

</aura:component>

controller.js

({
    doInit : function(component, event, helper) {
        var createRecordEvent = $A.get("e.force:createRecord");
      createRecordEvent.setParams({
         "entityApiName": "Contact" // using account standard object for this sample
      });
      createRecordEvent.fire();
    }
})

output is: Expecting to remove that empty modal.

output

  • Hi, is there a reason you can't use the standard New Contact button on the Account's Contact related list? I'm not clear on why you need a Lightning Action to do this. – Nicholas Zozaya Mar 2 at 6:07
  • @NicholasZozaya My target is to have a button on top of account...which will navigate me to creating a contact (in lightning) – user3338134 Mar 5 at 12:17
  • I understand what your issue is but don't think there is a solution for this yet - check this post out as it''s about same issue and suggests some workarounds. salesforce.stackexchange.com/questions/170291/… – Nicholas Zozaya Mar 6 at 3:28
0

You can use an action with following details.

Type: Create a Record
Target Object: Contact

You dont even have to use lightning component for this.

  • This will ask me to select the fields to display for new contact creation. I want to have same layout(new contact from contact tab) – user3338134 Mar 5 at 12:15
0

You should wait a few seconds in order to fire the "hide" event for the quick modal, something like this:

window.setTimeout(
    $A.getCallback(function(){
        const createRecordEvent = $A.get('e.force:createRecord')
        createRecordEvent.setParams({
            entityApiName: 'My_Object__c'
        });
        createRecordEvent.fire();
         $A.get('e.force:closeQuickAction').fire();
    }), 2000
);

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.