Timeline for How do I pass a SObject record from LWC to a custom Apex method to persist data?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 21, 2019 at 14:56 | comment | added | Jayant Das |
@DavidCheng You will need to create that manually using let . The approach is similar to as it is for aura components
|
|
Aug 21, 2019 at 14:45 | comment | added | David Cheng |
@JayantDas When you create the JSON contact let cont = { 'sobjectType': 'Contact' }; , can you tell me where this is documented? When I create a contact using Contact con = new Contact(); and then JSON.serialize(con); , I see "type":"Contact" instead of sobjectType .
|
|
Apr 11, 2019 at 14:05 | vote | accept | Jayant Das | ||
Apr 18, 2019 at 2:02 | |||||
Apr 9, 2019 at 12:08 | comment | added | Pranay Jaiswal | No compile time or run time error. It deserialized only the fields present on the contact. If you want string binding you can import feildName. gist.github.com/pranayjswl007/d0ef6305e8b4f0b084c48e74e5eb5a84 | |
Apr 9, 2019 at 11:47 | comment | added | Jayant Das | @PranayJaiswal Good to know this. Seems the platform deserializes it based on the parameter type as in the apex method. What is the behavior if you say add a field in your JS which does not exist in Contact? Does that give you a compile time error? | |
Apr 9, 2019 at 11:13 | comment | added | Pranay Jaiswal | Can you have a look at my Gist? I was able to create record without passing ` { 'sobjectType': 'Contact' };` gist.github.com/pranayjswl007/c5bec83bc2ff3b0c905edd9ecb3b34ae | |
Apr 9, 2019 at 10:54 | comment | added | Jayant Das | @PranayJaiswal This is not a real business use case but more from a learning perspective as how you can do so if you need it. | |
Apr 9, 2019 at 8:31 | comment | added | Pranay Jaiswal | Not sure if getting response in string is a good idea | |
Apr 9, 2019 at 1:28 | history | edited | Jayant Das | CC BY-SA 4.0 |
added 36 characters in body
|
Apr 8, 2019 at 20:19 | history | answered | Jayant Das | CC BY-SA 4.0 |