Create an account using Lightning Data Service in LWC

Using Lightning Data Service (LDS) and User interface API (UI API) we can work on data and metadata of salesforce. Records loaded in Lightning Data Service are cached and shared across components. Components accessing the same record see significant performance improvements, because a record is loaded once, no matter how many components are using it.
Now create a simple lwc component to create an account record using lightning-record-form.
lightning-record-form
createNewAccount.html
[<template>
    <lightning-card title="Create Account" icon-name="standard:account">
        <div class="slds-m-around_medium">
            <lightning-record-form
                object-api-name={accountObject}
                fields={accountFields}
                onsuccess={handleAccountCreated}
                columns="2">
            </lightning-record-form>
        </div>
    </lightning-card>
</template>]
 createNewAccount.js
[import { LightningElement } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent'; // for toast notification
import ACCOUNT_OBJECT from '@salesforce/schema/Account';  // import object
import AC_NAME from '@salesforce/schema/Account.Name';  // import fields
import AC_WEBSITE from '@salesforce/schema/Account.Website';
import AC_NUMBER from '@salesforce/schema/Account.AccountNumber';
import AC_INDUSTRY from '@salesforce/schema/Account.Industry';
import AC_RATING from '@salesforce/schema/Account.Rating';
import AC_PHONE from '@salesforce/schema/Account.Phone';
import AC_TYPE from '@salesforce/schema/Account.Type';

export default class CreateNewAccount extends LightningElement {
    accountObject = ACCOUNT_OBJECT;  // object type
    accountFields = [AC_NAME, AC_WEBSITE,AC_NUMBER, AC_INDUSTRY, AC_RATING, AC_PHONE, AC_TYPE]; // fields to be showin in form
    // shows toast message after account creation
    handleAccountCreated(){
        // Run code when account is created.
        const showSuccess = new ShowToastEvent({
            title: 'Success!!',
            message: 'Account has been created',
            variant: 'Success',
        });
        this.dispatchEvent(showSuccess);
    }
}]
You can also find the above code in SWDC WORLD

COMMENTS

Name

Apex,6,Batch Apex,2,Chrome Add-on,1,Chrome browser,1,Coding Best Practices,2,CRM Basics,1,cURL,1,Database Query,1,Dataset,1,Dynamic Apex,3,Dynamic SOQL,1,Einstein Analytics,9,Future Apex,1,Git,1,Google Chrome,1,JS for LWC,6,Lightning Components,2,lightning Page,1,Lightning Web Components,13,Linux for Windows users,1,LWC,2,Queueable Apex,1,Redirect page,1,REGEX,1,REST API,1,Salesforce CRM,1,Salesforce Errors,1,Salesforce Interview Questions,13,Salesforce Lightning,1,Salesforce New Features,1,Salesforce Tasks,2,Schedule Apex,1,Test Class,1,Triggers,1,Visualforce Pages,3,Visualforce Pagination,2,VS Code,2,Wave Analytics,7,Winter Release Notes,1,workbench,1,
ltr
item
SWDC WORLD (Software Development Center Of The World) - is a Multi author and Multi Technology Blog: Create an account using Lightning Data Service in LWC
Create an account using Lightning Data Service in LWC
Create an account using Lightning Data Service in LWC,create an account record using lightning-record-form,create new records in lwc without using apex calling,create a record form in lwc
https://1.bp.blogspot.com/-r1xImULZfpk/Xhwd0lG0t_I/AAAAAAAAAYY/0w4n4YTZeY4jjTVZucrz8y0wbE4yJqY7ACLcBGAsYHQ/s400/lightning-record-form.jpg
https://1.bp.blogspot.com/-r1xImULZfpk/Xhwd0lG0t_I/AAAAAAAAAYY/0w4n4YTZeY4jjTVZucrz8y0wbE4yJqY7ACLcBGAsYHQ/s72-c/lightning-record-form.jpg
SWDC WORLD (Software Development Center Of The World) - is a Multi author and Multi Technology Blog
https://swdcworld.blogspot.com/2020/01/create-account-using-lightning-data.html
https://swdcworld.blogspot.com/
https://swdcworld.blogspot.com/
https://swdcworld.blogspot.com/2020/01/create-account-using-lightning-data.html
true
5370056087523941001
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy