0

I have deployed my SP solution to farm successfully with some js files, those are added to layout mapped folder. Then I want the same solution to be deployed to SharePoint online. I just chaged the sandboxed property and deplyed. But endup with some errors says

"The deployment type "TemplateFile" of file "jquery-1.4.2.min.js" in Project Item "Layouts" is not compatible with a Package in a Sandboxed Solution."

What is the best solution to overcome this issue. It should solve my SharePoint online deployment too.

1 Answer 1

1

In Sharepoint online you can not deploy files to the _layouts folder as there is no _layouts folder there.

For Sandbox solutions, the Style Library is the correct location.

If you are going to keep them in the Style Library can try referencing the scripts using the ~sitecollection replacement token (generally Style Library is only provisioned at the root site within a site collection). You might be getting the errors described if you are in a subsite and the scripts are deployed to the root site of the site collection. For example:

<SharePoint:ScriptLink runat="server" Name="~sitecollection/Style%20Library/Scripts/jquery-1.7.2.min.js" Localizable="false"></SharePoint:ScriptLink>
<SharePoint:ScriptLink runat="server" Name="~sitecollection/Style%20Library/Scripts/jquery.SPServices-0.7.1a.js" Localizable="false"></SharePoint:ScriptLink>

How do I get my JS to work on sharepoint online?

2
  • This will work for sure. But I didn't try because expect a different solution. When we deploy the solution through VS, js files also should be deployed to SharePoint. This will work for farm solutions, but not for sandboxed. <script src="../../../_layouts/KnockOutSP/Scripts/MicrosoftAjax.js" type="text/javascript"></script> Sep 16, 2014 at 5:41
  • 1
    Because in sandbox solution you can not deploy on file system. This is by design.
    – Aanchal
    Sep 16, 2014 at 5:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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