I am a little bit confused. Knowing that not all features which are available in a pure aura project are exposed to Lightning Components I thought it is mandatory to check against the Salesforce developer documentation.

So in the auradocs/reference.app below the JavaScript API section I found the function $A.set() giving this example:

$A.set("$Custom.something","new Value")

Unfortunately this does not work, giving me an error "Unable to set value for key". So my assumption is that I have to define a global value provider with the appropriate key first. When you search the Salesforce developer documentation against global value provider you get the first result showing up:


It seems that the search result is not within the scope of the Lightning Components as it does not show up in the navigation.

Does anyone have an idea how

  • $A.set() is working
  • I can add a custom global value provider or any other mechanism to store data in a manner known as Singleton

Thanks in advance


  • I think what you're looking for is on this page: developer.salesforce.com/docs/atlas.en-us.lightning.meta/…
    – crmprogdev
    Commented Mar 22, 2016 at 15:45
  • Thanks for the link, but I thinks it is not 100% I was looking for - I really want to store data (not custom labels) global to use across components (even to know that this should be handle with care). So my assumption is that there are more global value provider available rather then $Label, $Browser and $Locale Commented Mar 23, 2016 at 12:40
  • You want to "store" data values as in having them stored as part of a "utility" component?? It would seem to me that this defeats the purpose of having recognizable Global Variables that any component can handle. There's really nothing to write to. The best you could do would be to store them in a list or map that you declare as part of your component or event handler. Otherwise, you'd seem to be looking at retrieving them from a custom setting; a bit difficult to do from the browser side.
    – crmprogdev
    Commented Mar 23, 2016 at 13:52
  • You said "There's really nothing to write to" -> that is what I wanted to clarify by this post as $A.set() in my eyes - with the giving example $A.set("$Custom.something","new Value") - seems like to do so. Nevertheless, thank you for sharing your ideas Commented Mar 23, 2016 at 14:57
  • If you looked closely at the code in the examples I pointed you to, they were using $A or $Label to populate the value of a component variable as in v.attribute. That's the type of thing they'd also be using $A.set for as well. I'd think of it as being comparable to setting a general attribute for the life of a visualforce component.
    – crmprogdev
    Commented Mar 23, 2016 at 15:05

2 Answers 2


$A.set() isn't exposed in Lightning Experience.

You can check this blog post re: client-side shared singleton (across components):



Take note of and read the pink section at the bottom of that page I pointed you to earlier in my comments. You can't use a string like 'Hello {0}' to tell it what to set the v attribute with. Instead, you must use an expression like $Label.mySection.salutation.

What you're doing is using that expression to tell Lightning (using object oriented expressions) how it should assign values to your v attributes. You're approaching it from the opposite direction by setting $Label.mySection.salutation to Hello {0}. That's how you accomplish what you want to do. Change the value assigned to $Label.mySection.salutation and you'll get a different behavior/result in your component.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .