I have a custom setting of either Hierarchy or List type.

I would like to access it from javascript outside of a visualforce page. i.e. On an HTML page or in a button script.

How would one implement this? Any ideas?


Same as you would access them in visualforce:

<script  type="text/javascript">
    var url = "{!$Setup.MyCustomSet__c.URL__c}";

If you google you won't miss it :)! Source

  • tried but is is not working. so now i am querying custom setting. – Pankaj Sep 4 '14 at 5:17
  • What do you mean by not working? Do you have erros on the page? Is the setting public? I've used this method many times and it always seems to work for me... – Boris Bachovski Sep 4 '14 at 5:21
  • I am using it like var url = "{!$Setup.MyCustomSet__c.URL__c}"; alert(url); and in alert i am getting the same message {!$Setup.MyCustomSet__c.URL__c} – Pankaj Sep 4 '14 at 6:03
  • 1
    Forgot to mention that this only works with hierarchy. I've just tested exact same scenario and worked like a charm – Boris Bachovski Sep 4 '14 at 6:36
  • 1
    this doesn't appear to work in a static resources that are javascript. – Tyler Zika Jun 26 '18 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.