You need to sign in to do that
Don't have an account?
Ken Koellner @ Engageware
LWC Lightning Web Component to both Create and Edit
I want to start prototyping a Lightning Web Component to create AND edit a record in a custom object. All the examples I found have one component for Edit and one Component for Create.
Anyone have an example of a component that does BOTH edit AND create?
It states "In the below code if I don't provide `record-id` then I can use the same tag to create a new record. If recordId is provided then we can update the record."
All Answers
Try Below Code Please Mark It As Best Answer If It Helps
Thank You!
You can combine both functionality in one Component according your requirement,
you should get reference from these links:
https://salesforce.stackexchange.com/questions/274109/how-to-embed-multiple-lightning-web-components-using-lightning-layout
https://www.sfdcpoint.com/salesforce/lightning-record-edit-form-lwc/
If you find your Solution then mark this as the best answer.
Thank you!
Regards,
Suraj Tripathi
I should qualify that I want to customize the fields an the page so I'd be using lightning-record-edit-form with lightning-input-field and additional custom code. (That's for the suggestion Charu but lightning-record-form won't allow me to custom code the interface.)
If I look here -- https://developer.salesforce.com/docs/component-library/bundle/lightning-record-edit-form/documentation I see
And for Create --For Edit --
I don't want to repeat the whole tagging for the fields for both Create and Edit.
Does anyone know if the first form can be used for create passing null for the record id? It seems like there out to be a way to code it only once and have it work for Create and Edit.
For the Updation you need to pass record Id:-
creaton time:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
The prior answer repeats what I posted in my follow up. I see in the manual an emample of how to code a create and an edit and I posted that above.
What I'm trying to find it is if there's a way to combine them and have one set up tags do both. Otherwise, suppose I have a page with 50 entry fields. I'd have to code that same list of fields twice, once within the edit tag and once within the create tag.
It states "In the below code if I don't provide `record-id` then I can use the same tag to create a new record. If recordId is provided then we can update the record."