SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to access my property bag using Javascript from a

          function getWebProperty() {

        var ctx = new SP.ClientContext.get_current();
        var web = ctx.get_site().get_rootweb();
        this.props =  web.get_allProperties();
        this.props.set_item('aProperty', 'it worked!');

        ctx.executeQueryAsync(Function.createDelegate(this, gotProperty), Function.createDelegate(this, failedGettingProperty));

    function gotProperty() {

    function failedGettingProperty() {

But I am getting an error saying " Object has no method 'get_rootweb'. I imagine this is because I haven't registered the sp.js library. If thats the problem, how would I register the sp.js library inside my elements.xml file? (Its all contained inside a element. If thats not the problem, is there a better way to access the property bag using javascript inside a element?

share|improve this question
what is ctx.get_site() returning? – Abe Miessler May 25 '12 at 23:44
up vote 5 down vote accepted

I agree with Derek's answer that you have a casing issue. Your issue should be solved by that. Regarding your second question: if you want to make sure that the sp.js is loaded on the page before your code executes, you can do that the following way through elements.xml:

   //Your JavaScript Code here.
share|improve this answer
Is there a way to access a specific propertybag as opposed to allproperties? – Meyer Denney May 29 '12 at 18:31
Sorry for the late reply but I am not really sure what you mean. Do you want to access the property bag of a specific web? – Vardhaman Deshpande Jun 17 '12 at 19:31
You can create your own custom property bag for your site collection. I am trying to access that property bag. I got it figured out, see the question… for more details – Meyer Denney Jun 17 '12 at 20:13

You have a casing issue. The correct format is

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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