4

Communities are implemented as Single Page Applications, so all the "pages" are actually rendered as one and are simply switched between by the view management within it. LWC wires leverage client-side caching (which is why the Apex they connect to must be cacheable). Put these two things together and what you are seeing is that "page A" ...


4

Is the above code working as designed? Yes. What is the best practice to get the new Label value as soon as it changes in salesforce? In practice, labels rarely change, if ever. You should use the import label statement for performance reasons. Is there any way I can use refreshApex() in this context? You can call that on the method, but that's overkill....


3

Option 1: It is because the scope of refresh method is not same as McwfPreInit when the event is fired. You need to use arrow function so that it will not have its own scope and the scope will always be same as McwfPreInit when event is fired. refresh = () => { console.log('event received'); this.loaded = false; this.trackedSteps = {}; ...


3

It doesn't. We use refreshApex without such a requirement. That same documentation specifies the signature for refreshApex as: refreshApex(valueProvisionedByWireService) I.e. there is no return value, so doing return refreshApex(value) simply returns undefined, which is equivalent to not using a return statement at all.


2

For refreshApex to work, you need to pass complete response, not just the data part. import { refreshApex } from '@salesforce/apex'; export default class LwcCaseCritical extends LightningElement { caseCriticalControllerApex backupResponseFromWire; @wire(caseCriticalControllerApex, {caseid: '$recordId'}) getcaseCriticalControllerApex(resp) { ...


2

The first method "does nothing" because the call is asynchronous, so from the browser's point of view, the flag effectively never changed. The second method doesn't work for the same reason; refreshApex is still running when you set the flag back to false. The third method fails because, as you said, the wire method only updates if there's actually new ...


2

Refresh apex needs to be called on wiredProperty itself, not data. @wire(getApexData, { pageNumber: '$pageNumber' }) wiredInfo(value) { this.wiredApexData = value; if (value.data) { this.apexData = value.data; this.error = undefined; } else if (value.error) { } } now call refresh apex on wiredApexData. refreshApex(this....


2

You need to keep the original wire data in order to work: wiredAccountsResult; wiredAccounts(wiredResult) { let { error, data } = wiredResult; this.wiredAccountsResult = wiredResult; ... And then: refreshApex(this.wiredAccountsResult); Also, you don't need to call it twice: // This refresh wasn't necessary // // refreshApex(this.wiredAccountsResult); ...


2

This is resolved in the Winter 21 release. A new method allows you to notify the runtime that a record has definitely changed and needs to be refreshed: import { LightningElement, wire } from 'lwc'; import { getRecord, getRecordNotifyChange } from 'lightning/uiRecordApi'; import apexUpdateRecord from '@salesforce/apex/Controller.apexUpdateRecord'; export ...


2

I have had success with clearing the draft values on the lightning-datatable by directly editing the draftValues property on the lightning-datatable DOM element. This seems to remove the Save and Cancel buttons and clear the yellow highlighting from the cells you edited: this.template.querySelector("lightning-datatable").draftValues = [];


2

It is kind of bad practice to start making exceptions for code that runs only in a sandbox context. Since you are relying on this code to execute correctly over time, why not write testmethods to assure yourself that on each regression test run, that the code does what you want. If you need to make sure this code never runs in PROD, gate the code by testing ...


1

You're using those async/await/promises incorrectly. You need to pick either async/await or promise/then/catch, but not both. Further, wire methods fire automatically, so you only need to refresh if you know you've change the data and need the latest version. You definitely do not need both methods. Unless you have a need, I'd go with the simple version. ...


1

Below quotes are from the Data table inline editing documentation, where you can see a similar scenario to you being called out (Apex updates from onsave datatable): First, the "Save" and "Cancel" buttons will only go away when you clear the draftValues property which it doesn't appear you've done. After making changes, when a user ...


1

Refresh apex does not work on just the data but the whole result of wired apex. So you need to make some changes to your code. wiredDataRes; @wire(getAllData, {recordId:'$recordid'}) wiredData(result) { this.wiredDataRes = result; let {error, data} = result; if (data) { this.data = data; } else if(error) { this.error = error;...


1

You don't need to use the returned value, but refreshApex does return a promise which is often times useful. If you want logic to fire after the completion of the refresh (usually meaning using the latest version of the data), then you need to interact with the promise since it happens asynchronously. The returned promise can be chained so in your example ...


1

I don't see the @wire for wiredPendingProgramDataRefresh property. Calling getStudentProgramTypes() in your file does not setup the wire service. When using the @wire decorator, you can either set a property or call a function. Property - you can just pass the set property to refreshApex(). Example: Refresh the Cache for a Wired Property Function - make ...


1

The problem is at below line: this.wiredRslt = result.data; Change it with this line below in order to make it work: this.wiredRslt = result;


Only top voted, non community-wiki answers of a minimum length are eligible