You need to sign in to do that
Don't have an account?
$A is not defined in LWC, working fine in one sandbox but not in other
I want to refresh the view of LWC using eval("$A.get('e.force:refreshView').fire();"); but scripting error "$A is not defined". It's interesting as the same code is working fine in one sandbox but not in another.
Apex Code Development
> It's strange that it works in another sandbox because the $A syntax is specific to Aura components and is not available in LWC.
> Are there any relevant differences in the components, modules, or features being used in the two sandboxes?
> Can you share the context in which the code is being executed? Is the code placed within LWC and not an Aura component or other context?
Alternatively, have you tried to use the the standard refreshApex method instead of $A.get('e.force:refreshView').fire(); in LWC.
Example:
import { refreshApex } from '@salesforce/apex'; // Call this function to refresh the view refreshView() { // Refresh the data using refreshApex return refreshApex(this.yourQueryResultVariable); }Related: https://salesforce.stackexchange.com/questions/340138/lwc-variable-not-defined________________________
Important Update - last chance
Heads up — this is your last chance to get your Trailblazer account set up and connected to your forums discussions on this site.
Please take these steps before November 30, 2023, 11:59 p.m. PT to ensure your contributions follow you to the Trailblazer Community:
- If you’re not already a member of the Trailblazer Community, sign up for a Trailblazer account using the same login email address associated with your Developer Discussion Forums account. This is crucial.
- If you already have a Trailblazer account, and it’s using a different email address from your Developer Discussion Forums account, we recommend that you log in to the Trailblazer Community and connect your forums email address to your Trailblazer account.
Find more info & supportWe know that moving platforms can be a hassle, so we created a special forums users group, the Migration Support Hub, in the Trailblazer Community where you can find other forums users and get training videos, the latest information, and assistance.
We want to thank you for all of your time, energy, and contributions made here in the Salesforce Discussion Forums.
We’ll see you in the Trailblazer Community!
Sincerely,
The Forums Support Team