Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Lightning Component Button to open New Account in Salesforce #66

Open
vijayk3327 opened this issue Aug 27, 2023 · 0 comments
Open
Assignees
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@vijayk3327
Copy link
Owner

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 details, Click Here →

👉 To get source code live demo link, Click Here.

**Create Lightning Component
Step 1:- Create Lightning Component : openNewAccountCmp.cmp
**

`<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

`({
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();
},

})`

👉 To get source code live demo link, Click Here.

@vijayk3327 vijayk3327 added documentation Improvements or additions to documentation question Further information is requested labels Aug 27, 2023
@vijayk3327 vijayk3327 self-assigned this Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
Status: No status
Development

No branches or pull requests

1 participant