Reputation: 95
So we have a lightning button which calls a LWC component. This LWC component opens up in a popup window with Save and Cancel button.
Now on the click of Cancel button the below LWC js code is called:
eval("$A.get('e.force:refreshView').fire();");
this.dispatchEvent(new CloseActionScreenEvent());
When I click on Cancel button, instead of closing the popup window I get the below error, saying:
[$A is not defined]
But the strange part is, the above syntax works fine in my dev sandbox but DOES NOT work in my one level up test sandbox. Any suggestions here?
Upvotes: 0
Views: 415
Reputation: 19637
You know you're using a hack? Syntax stolen from Aura components that officially shouldn't be used in LWC? Eval is evil and all that? Maybe your next sandbox has stronger Lightning Locker / Lightning Web Security enabled. Maybe it's on Winter preview and they clamped down on this hack?
Any special reason you can't use proper RefreshView API? Or similar ones like notifyRecordUpdateAvailable
?
import { RefreshEvent } from "lightning/refresh";
// ...
handleClose() {
this.dispatchEvent(new RefreshEvent());
}
Upvotes: 1