function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MadeForITMadeForIT 

Creating records of multiple object with single button in LWC

I have requirement of creating a LWC in which i have 8 fields from 2 different Objects. After user has entered the data, on click of 1 button, records should be saved in respective objects. 
Basically is there any way to save records of multiple objects with a single save button? 
I know how to create record in LWC using Apex, using Lightning/UI RecordApi and lightning-record-edit-form,  But all of these to save records in a single object with one button click.
please help me out.
Surya GSurya G
HI Aastha,
Yes, we can do this in single button click. For that we have to use our own html forms to get values from user as the lightining record forms wont be heplful here for 2 objects.
1, built a custom lwc that takes values for all the fields (not to use lightning-record-edit-form).
2, on click of save button, send those values as wrapper object to your controller class. In your controller class, match the values to the object and insert it seperately.

Thanks
Surya
PriyaPriya (Salesforce Developers) 
Hey Aastha,

You can refer these link :- 

https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8iE1SAJ

https://sfdcflight.blogspot.com/2020/05/salesforce-lwc-multi-record-creation.html

Thanks!
MadeForITMadeForIT
@Surya G Thank you. It worked:)