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
Team AppSharkTeam AppShark 

LWC standard update method is not reflecting the updates on detail page.

Best Answer chosen by Team AppShark
Danish HodaDanish Hoda
then(() => {                     this.dispatchEvent(                         new ShowToastEvent({                             title: 'Success',                             message: 'Record Is Updated',                             variant: 'Success',                         }),                     );                  location.reload();                 })                 .catch(error => {                     this.dispatchEvent(                         new ShowToastEvent({                             title: 'Error on data save',                             message: error,                             variant: 'error',                         }),                     );                 });  Sent from Yahoo Mail on Android

All Answers

Danish HodaDanish Hoda
Hi There,
Please check the data you are showing is marked with @track modifier
Team AppSharkTeam AppShark
Danish,

The data is updated in database, but it is not reflecting on UI.
Danish HodaDanish Hoda
Hi there,Please share your html code. Sent from Yahoo Mail on Android
Team AppSharkTeam AppShark
Danish,

Did you get my point, am using LWC as a component to update some fields after clicking update the values are updated in databse and it is navigated to Detail page but the detail page UI is not reflected with updated values, they are reflected once we refresh the page.
Danish HodaDanish Hoda
Ok, this is because your page is not reloading properly on nivigation.
Please use location.reload(); to reload the page.
Team AppSharkTeam AppShark
Where should I use location.reload();  
am using below standard Updaterecord function which automaltically navigates to Detail Page.
updateRecord(record)
                // eslint-disable-next-line no-unused-vars
                .then(() => {
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Success',
                            message: 'Record Is Updated',
                            variant: 'Success',
                        }),
                    );
                })
                .catch(error => {
                    this.dispatchEvent(
                        new ShowToastEvent({
                            title: 'Error on data save',
                            message: error,
                            variant: 'error',
                        }),
                    );
                });
Danish HodaDanish Hoda
then(() => {                     this.dispatchEvent(                         new ShowToastEvent({                             title: 'Success',                             message: 'Record Is Updated',                             variant: 'Success',                         }),                     );                  location.reload();                 })                 .catch(error => {                     this.dispatchEvent(                         new ShowToastEvent({                             title: 'Error on data save',                             message: error,                             variant: 'error',                         }),                     );                 });  Sent from Yahoo Mail on Android
This was selected as the best answer
Team AppSharkTeam AppShark
Thanks Danish, it worked.
Team AppSharkTeam AppShark
Danish, 
i am facing some awkward issue in LWC, for the very first time when I am using LWC component to update the records it throws below error

![Attached image](/api/3/files/20914771/preview/image-1586948929204.png)
Team AppSharkTeam AppShark
Danish, 
i am facing some awkward issue in LWC, for the very first time when I am using LWC component to update the records it throws below errorUser-added image
Danish HodaDanish Hoda
Hi there,
Please check the console.log for better view of the error, it is going inside catch statement. something is failing at the apex end.
Team AppSharkTeam AppShark
Yeah i have checked but no error is displayed and moreover am not calling any apex methods, am using standard LWC create record method.
Danish HodaDanish Hoda
Please check the debug log
Rick Paugh 12Rick Paugh 12
Is there really no way to do this without reloading the entire page?