0

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?

1 Answer 1

1

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());
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.