Creating a New Account in Salesforce Using Aura Components
Salesforce is a powerful platform that allows developers to create robust and scalable applications for businesses. One of the key features of Salesforce is its ability to customize and extend functionality through the use of Lightning components. In this blog post, we will explore a simple example of creating a new account using an Aura component in Salesforce.
Aura Component Overview
This component is designed to be available for all page types and provides a user interface for creating a new account.
This Aura component consists of a card with input fields for the account name, site, phone, and rating. The 'Save' button triggers the
insertAcc
controller method when clicked.Controller JavaScript
Now, let's take a look at the JavaScript controller that handles the button click and initiates the server-side action:
The
insertAcc
method retrieves the account information from the component, sets up a server-side action (newAccRecord
), and enqueues the action for execution.Server-Side Apex Controller
Finally, the server-side Apex controller (NewAccount.cls
) handles the creation of the new account record:
The
newAccRecord
method is annotated with @auraEnabled
, making it accessible from the Aura component. It attempts to insert the provided account, and any exceptions are caught and can be handled as needed.
0 Comments