Insert New Record in Custom Object in lwc -- w3web.net

Insert New Record in Custom Object and Navigate to the Record Detail Page Using Apex class method in Lightning Web Component — LWC | Insert record and navigate to record detail page in lwc

4,815 views

Hey guys, today in this post we are going to learn about How to Insert New Record in Custom Object and Navigate to the Record on Detail Page Using Apex class method in Lightning Web Component — LWC.

Files we used in this post example:-

insertRecordCustomObjectLwc.html Lightning Web Component HTML Template HTML file for used to write HTML element for user interface..
insertRecordCustomObjectLwc.js Lightning Web Component JavaScript It is holding submitAction function that is geting the value from input field and save into the database.
insertRecordCustomObjectLwc.js-meta.xml XML Meta File It is used for where this lightning web component you want to exposed
lwcAppExampleApex.cls Apex Controller It is used for call apex method imperatively in LWC Javascript file.

Live Demo

create record for custom object using lwc -- w3web.net

Other related post that would you like to learn in Salesforce

Step 1:- Create Lightning Web Component : insertRecordCustomObjectLwc.html

SFDX:Lightning Web Component >> New >> insertRecordCustomObjectLwc.html

insertRecordCustomObjectLwc.html [Lightning Web Component HTML]

Step 2:- Create Lightning Web Component : insertRecordCustomObjectLwc.js

SFDX:Lightning Web Component >> New >> insertRecordCustomObjectLwc.js

insertRecordCustomObjectLwc.js [LWC JavaScript File]

Step 3:- Create Lightning Web Component : insertRecordCustomObjectLwc.js-meta.xml

SFDX:Lightning Web Component >> New >> insertRecordCustomObjectLwc.js-meta.xml

insertRecordCustomObjectLwc.js-meta.xml [LWC Meta Data XML]

Step 4:- Create Apex Controller : lwcAppExampleApex.cls

SFDX:Create Apex Class >> New >> lwcAppExampleApex.cls

lwcAppExampleApex.cls [Apex Class]

Insert New Record in Custom Object in lwc -- w3web.net

Further post that would you like to learn in Salesforce

 


 

FAQ (Frequently Asked Questions)

How do you create a new record in LWC?

Create a lightning web component ldsCreateRecord. Use lightning-input to get the user input for Account Name, Account Number, and Phone. Add lightning-button to call the JS controller method to create the record. Add onchange handler for each lightning-input tag to get the updated value in the JS controller.

How do you update LWC records?

Whenever you want to update a record you can use LDS methods which is updateRecord if the LDS tags are not of any help! It's a method that we need to import from the package lightning/uiRecordApi and invoke it by passing the appropriate config object.

How do you save records in LWC?

To create a record using lightning-record-form , leave out the record-id attribute. This example creates a record using import references for the account object and its fields. The form displays a Save button that updates the record, and a Cancel button that reverts changes.

Related Topics | You May Also Like

  • Your reaction of the article ▾
 

Hi, I am a senior software developer and working in MNC company from more than 8 years. I am great fan of technology, configuration, customization & development. Apart of this, I love to write about Blogging in spare time, Working on Mobile & Web application development, Salesforce lightning, Salesforce LWC and Salesforce Integration development in full time. [Read full bio] | | The Sitemap where you can find all published post on w3web.net

13 thoughts on “Insert New Record in Custom Object and Navigate to the Record Detail Page Using Apex class method in Lightning Web Component — LWC | Insert record and navigate to record detail page in lwc”

  1. Hi. your post is so nice and I really loved reading your post.
    It was very well authored and easy to understand. Great Thanks for sharing awesome info. I really love to read your blog.

    Reply
  2. for testing – i created the object, fields, and the code of course.
    The Show Toast is working and the record is also getting created but the navigation is not working

    Reply

Leave a Comment