Code Segment: createAccount.js

Code Segment - createAccount.js

Here is the saveAccountRec() function in our JavaScript controller:

createAccountJs-saveAccountRec()

To support a modular design, I perform the new account creation in a separate function called createAccount().

createAccountJs-createRecord()

In the segment above we see the call to createRecord().

When creating a new account record, the only required field is the Account Name. Let’s create a record to see how it looks to the user:

Vh2ndCrud-CreateAccount-AcmeAssoc

After we enter data and click on the Create button, we’ll get a toast Success message and we’ll be taken to the default account home screen, where we will see our new record:

Vhe2ndCrud-RecentlyViewedAcconts-Acme

That’s it! We have used the CreateRecord() function in the lightning/uiRecordApi to handle the C (Create) in our CRUD example.

Advantages of the uiRecordApi