Create a Lightning Component Button to open New Account in Salesforce | Lightning Button to Create New Contact in Salesforce | Create a Lightning Component button to open New Lead in Salesforce

2,483 views


Hey guys, today in this post we are going to learn about How to Create a Lightning Component Button to open New Account in Salesforce.

Create a Lightning Component Action

Creating a Lightning component action is similar to creating a regular quick action, and you do it in the same place in Setup. All you need is a Lightning component in your org for the quick action to trigger. To know more, Click Here.

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!

 

 

Final Output →

button to create new record salesforce lightning -- w3web.net

 

You can download file directly from github by Click Here.

 

Other related post that would you like to learn in Salesforce

 
button to create new record salesforce lightning -- w3web.net
 

  • Find the below steps ▾

 

Create Lightning Component

Step 1:- Create Lightning Component : openNewAccountCmp.cmp

From Developer Console >> File >> New >> Lightning Component

Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 

openNewAccountCmp.cmp [Lightning Component File]

  1.   <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" description="c:openNewAccountCmp">
  2. 	<lightning:card title="Create Account" iconName="standard:account" >
  3.  
  4.     <div class="slds slds-p-around_medium">
  5.         <button class="slds-button slds-button_brand" onclick="{!c.createAccount}" >Create Account</button>        
  6.     </div>
  7.  
  8.      <div class="slds slds-p-around_medium">
  9.          <button class="slds-button slds-button_brand" onclick="{!c.createContact}" >Create Contact</button>       
  10.     </div>
  11.  
  12.  
  13.       <div class="slds slds-p-around_medium">
  14.           <button class="slds-button slds-button_brand" onclick="{!c.createLead}" >Create Lead</button>        
  15.       </div>   
  16.  
  17.     </lightning:card>     
  18. </aura:component>

 

Create JavaScript Controller

Step 2:- Create Lightning Component : openNewAccountCmpController.js

From Developer Console >> File >> New >> Lightning Component >> JavaScript Controller

openNewAccountCmpController.js [JavaScript Controller]

  1.   ({
  2. 	createAccount : function (component, event, helper) {
  3.         var createRecordEvent = $A.get("e.force:createRecord");
  4.         createRecordEvent.setParams({
  5.             "entityApiName": "Account"
  6.         });
  7.         createRecordEvent.fire();
  8.     },
  9.  
  10.     createContact : function (component, event, helper) {
  11.         var createRecordEvent = $A.get("e.force:createRecord");
  12.         createRecordEvent.setParams({
  13.             "entityApiName": "Contact"
  14.         });
  15.         createRecordEvent.fire();
  16.     },
  17.  
  18.     createLead : function (component, event, helper) {
  19.         var createRecordEvent = $A.get("e.force:createRecord");
  20.         createRecordEvent.setParams({
  21.             "entityApiName": "Lead"
  22.         });
  23.         createRecordEvent.fire();
  24.     },
  25.  
  26.  
  27. })

 

 

Further post that would you like to learn in Salesforce

 

 


 

FAQ (Frequently Asked Questions)

How do I Create a dynamic button in Salesforce lightning?

Edit an existing record page, or click New to create one. Add or select the Highlights Panel component on the object's record page. In the Highlights Panel properties pane, click Upgrade Now to enable Dynamic Actions, and either step through the migration assistant to migrate existing actions or start with new actions.

How do I add custom action buttons?

Select Settings | Custom Actions. Select Create. Then give your custom action button a name and select whether you want the button to appear on selected base objects and on desktop and mobile apps.

How do I create a quick action button in LWC?

As we are creating this action for the Opportunity Record Page, it is an object-specific action. Navigate to the Opportunity Object in Setup. Under Button, Links, and Actions. Create a new Action.

Related Topics | You May Also Like

 
Note:: – You will get an email, so put correct email and mobile number and BEGIN YOUR JOURNEY from Today!
 
 
  

Our Free Courses →

👉 Get Free Course →

📌 Salesforce Administrators

📌 Salesforce Lightning Flow Builder

📌 Salesforce Record Trigger Flow Builder

👉 Get Free Course →

📌 Aura Lightning Framework

📌 Lightning Web Component (LWC)

📌 Rest APIs Integration



Hi, This is Vijay Kumar behind the admin and founder of w3web.net. I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

Leave a Comment