2

I want to do some java-script operation on a custom list in SharePoint 2013 Online version. So I am creating a separate java-script file and deploying to Style Library manually.

Does anybody know how to deploy java-script file into Style Library of a site collection automatically in Sharpoint 2013 App for online ? Also where the app.js file from SharePoint App Solution is deployed?

5

I'll start out by defining two terms, the Host Web and the App Web. The SharePoint site where you install an App is called the Host Web. The SharePoint site where the SharePoint-Hosted App lives is called the App Web. The App Web is a child site of the Host Web.

A SharePoint-Hosted App can automatically deploy files inside the App Web using a Module element but it cannot automatically deploy files to the Host Web or the Site Collection containing the Host Web. To do what you want to do you would deploy the JavaScript file to the App Web and then use code to read it and add it to the Style Library in the Host Web's Site Collection root.

This blog post shows how to deploy a master page from an App to the Master Page Gallery. You can use the same technique to deploy a JavaScript file to the Style Library.

http://www.sharepointnutsandbolts.com/2013/05/sp2013-host-web-apps-provisioning-files.html

  • 1
    Take note though: 'Anyway, apps can provision to the host web IF: •The app requests (and is granted) “Full Control” permission of the host web ◦Note this means it cannot be sold via the Office/SharePoint Store (see Validation checklist for apps for Office and SharePoint). But it can be deployed internally through the organization’s App Catalog.' /via the blog post linked above. – Ryan Shripat Mar 18 '15 at 13:51
0

If your building this is in visual studio the your JS files will get deployed automatically via the features.

If this is a "Sharepoint Hosted" app then you publish directly to your dev site OR publish an app file which then gets added to your app catalogue.

I would keep all your JS files in the same Script or Javascript folder.

Once deployed the files will maintain the same structure as they are in VS. Something like

https://domain.sharepoint.com/sites/name-of-site/name-of-app/pages/default.aspx (if you had a folder called pages where you put all your pages!)

so if you want to view the JS file you would use

https://domain.sharepoint.com/sites/name-of-site/name-of-app/scripts/app.js

Cheers.

S

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.