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.
Final Output β
You can download file directly from github by Click Here.
Other related post that would you like to learn in Salesforce
- Find the below steps βΎ
Create Lightning Component
Step 1:- Create Lightning Component : openNewAccountCmp.cmp
From Developer Console >> File >> New >> Lightning Component
openNewAccountCmp.cmp [Lightning Component File]
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" description="c:openNewAccountCmp">
<lightning:card title="Create Account" iconName="standard:account" >
<div class="slds slds-p-around_medium">
<button class="slds-button slds-button_brand" onclick="{!c.createAccount}" >Create Account</button>
</div>
<div class="slds slds-p-around_medium">
<button class="slds-button slds-button_brand" onclick="{!c.createContact}" >Create Contact</button>
</div>
<div class="slds slds-p-around_medium">
<button class="slds-button slds-button_brand" onclick="{!c.createLead}" >Create Lead</button>
</div>
</lightning:card>
</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]
({
createAccount : function (component, event, helper) {
var createRecordEvent = $A.get("e.force:createRecord");
createRecordEvent.setParams({
"entityApiName": "Account"
});
createRecordEvent.fire();
},
createContact : function (component, event, helper) {
var createRecordEvent = $A.get("e.force:createRecord");
createRecordEvent.setParams({
"entityApiName": "Contact"
});
createRecordEvent.fire();
},
createLead : function (component, event, helper) {
var createRecordEvent = $A.get("e.force:createRecord");
createRecordEvent.setParams({
"entityApiName": "Lead"
});
createRecordEvent.fire();
},
})
Further post that would you like to learn in Salesforce
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
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 |