Certified Platform Developer II Exam QuestionsBrowse all questions from this exam

Certified Platform Developer II Exam - Question 243


A developer is creating a Lightning web component that displays a list of records in a lightning-datatable. After saving a new record to the database, the list is not updating.

What should the developer change in the code above for this to happen?

Show Answer
Correct Answer: C

Discussion

5 comments
Sign in to comment
BruceParkOption: D
Aug 19, 2023

Isn't it D? Because records is a wire function and assigns the result to this.data. So, this.data is the variable currently holding the displayed data.

Sri0507Option: D
Dec 18, 2023

It should be D. https://bobbuzzard.blogspot.com/2022/01/refreshapex-and-lightning-web-components.html https://developer.salesforce.com/docs/platform/lwc/guide/apex-result-caching.html

dasabhisek404
Jun 29, 2024

go through carefully. It should be C

MarkusTOption: C
May 26, 2024

C is correct. The "data" variable only stores the "data" part of "result". However, following the same link everyone posted here, salesforce docs clearly say that the wired function should use the entire "result" parameter in a wired function. Hence, we need to store "result" in a new variable and then call refreshApex on it.

Yas010101Option: D
Jan 10, 2024

https://developer.salesforce.com/docs/platform/lwc/guide/apex-result-caching.html

dasabhisek404Option: C
Jun 29, 2024

C is correct, you have to send whole result into refreshApex to get latest data.