How to get the Version Number of a SharePoint-Hosted App in JavaScript

Published on Author Rob Windsor2 Comments

I spent some time a while ago trying to figure out how the get the version number of a SharePoint-Hosted App in JavaScript code. After a bunch of Googling and building demo Apps I gave up with the assumption that this information was not available.

This morning I was writing some code that worked with the property bag (AllProperties) values of the AppWeb. In there I noticed a property named Version. Hold on, could it be??? Yes, it could.

The value of the Version property in the App Web property bag is the version number of the App.  🙂

SP.Web.allProperties property

UPDATE (April 5, 2016):

It appears, as Ivan mentions in his comment, that the Version property is only added when you deploy using Visual Studio (i.e. during development). The property is not added when you install an app from the App Store or App Catalog. I’ve contacted Microsoft for more information about this but, as yet, I have not received a response.

The strategy I’m going to try is to use the version number of the Feature that is contained within the Sandbox Solution which is contained within the App. This does mean that the developer needs to keep the Feature version in sync with the App version, which is not optimal, but I don’t see a better way to solve the problem.

2 Responses to How to get the Version Number of a SharePoint-Hosted App in JavaScript

  1. Unfortunately, this appears to be only in apps deployed with Visual Studio. Apps added from the App Catalog do not have the Version property.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.