none
Provision property bag for document library declaratively via sandbox RRS feed

  • Question

  • I have a no-code sandbox solution that I use to provision artefacts. One is a document library to which I want to attach a property bag to be set by a user via custom setting page.

    I learned that one can not directly attach a property bag to a document library but only to its root folder. I know how to add property bags to items but did not succeed in adding those to a root folder.

    Any help appreciated.

    Friday, February 19, 2016 3:55 PM

Answers

  • Afaik you can't do that declaratively. What you can do is update the property bag via CSOM using a CustomAction with location=ScriptLink. Then, add the property bag values in a custom JavaScript library. That way, you'll still have a no-code sandbox provisioning settings. Of course, after the values have been added there's not much point anymore in keeping the feature provisioning the customaction active.

    Here's an example of setting the rootfolder property bag via CSOM: https://lixuan0125.wordpress.com/2013/10/18/add-and-retrieve-property-bag-by-csom/ 

    And here's a customaction example (which need to be deployed to sharepoint via a feature):

      <CustomAction Location="ScriptLink"
                    ScriptSrc="~siteCollection/Style Library/JavaScript/mycustomlibrary.js"
                    ShowInLists="true"
                    Sequence="1000"                
                    />


    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

    • Marked as answer by Juergen Riemer Saturday, February 20, 2016 3:34 PM
    Friday, February 19, 2016 4:09 PM
    Moderator

All replies

  • Afaik you can't do that declaratively. What you can do is update the property bag via CSOM using a CustomAction with location=ScriptLink. Then, add the property bag values in a custom JavaScript library. That way, you'll still have a no-code sandbox provisioning settings. Of course, after the values have been added there's not much point anymore in keeping the feature provisioning the customaction active.

    Here's an example of setting the rootfolder property bag via CSOM: https://lixuan0125.wordpress.com/2013/10/18/add-and-retrieve-property-bag-by-csom/ 

    And here's a customaction example (which need to be deployed to sharepoint via a feature):

      <CustomAction Location="ScriptLink"
                    ScriptSrc="~siteCollection/Style Library/JavaScript/mycustomlibrary.js"
                    ShowInLists="true"
                    Sequence="1000"                
                    />


    Kind regards,
    Margriet Bruggeman

    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

    • Marked as answer by Juergen Riemer Saturday, February 20, 2016 3:34 PM
    Friday, February 19, 2016 4:09 PM
    Moderator
  • Hi Margriet,

    Thanks a lot for having me kept from wasting a lot of time indeed ;)

    You gave me a great idea: I - in any case - need a custom list settings link with attached page to modify the property bag (via JSOM). Now I will use this very page to first check if there is a property bag and if not I'll simply create it!

    Great! Thanks Margriet!

    Saturday, February 20, 2016 3:41 PM