How to Send Wrapper Object to Apex from LWC?

We know how inconvenient it is to send wrapper object as most of the time, we need to use the existing apex method that takes it as a parameter. Today, our team of Salesforce experts has come up with a solution that allows you to send wrapper object to Apex from LWC. With this, it has got easier than ever! Let’s learn how you can achieve this.

Code

1. With this, you can directly pass the wrapper object to the apex without any serialization and deserialization process. Below is the wrapper class in Apex.

2. Now, we will use the wrapper object in the apex class to get data from LWC to insert Account and Contact Objects.

3. We will now pass this AccountWrapper object to the apex with JSON data in the method parameter in LWC.

Conclusion

See how easy it was! We hope that you liked our Salesforce solution and it was helpful for you. If you need to implement this or have any questions, then our experts can help. Also, if you try this solution for your business, then share your experiences with us. We will be back with another Salesforce solution soon. Till then, happy learning! 🙂 

Our Location worldwide
India
3rd Floor, A-10, Pegasus Tower, Sector 68, Noida, Uttar Pradesh 201301 +91-1203117884
SR Tower 2nd Floor Hydel Gate Haldwani Uttarakhand 263126 +91-5946359996
USA
333 West Brown Deer Road Unit G – 366 Milwaukee WI, USA 53217 +1(262) 310-7818
UK
7 Bell Yard, London, WC2A 2JR +44 20 3239 9428
Canada
HIC Global Solutions INC
43 Lafferty Lane, Richmond Hill, L4C 3N8, CA +1(262) 310-7818