SharePoint apps (add-ins) JavaScript disappeared

Jun 9, 2015

At Negotium we recently came across a weird problem.

Let’s assume you previously built a Provider hosted app for SharePoint.

Now let’s assume you updated to the latest version of the SDK (April/May update)

Finally let’s assume your tenant has been updated recently (v16.0.4121.1212 or above)

It’s likely that you are loading SP.*.js files and MicrosoftAjax.js the way it used to be recommended by Microsoft per say: <HostWebUrl>/_layouts/15/jsfile.js or <AppWebUrl>/_layouts/15/jsfile.js.

However MicrosoftAjax.js has been deprecated for several years now (replaced by EcmaScript 5 new features and jqueryval)

https://stackoverflow.com/questions/8782697/are-microsoftajax-js-microsoftmvcajax-js-and-microsoftmvcvalidation-js-obsolete

One effect of this tenant update is that is deletes MicrosoftAjax.js

Another thing I noticed is that the lastest sdk update (16.1.3912.1204) brings along SP.*.js files as we can see in the JavaScript folder of the nugget package.

95.png

It seems that Microsoft reviewed it’s strategy and now recommends to embed JS files within your application.

So I created a sharepoint folder in my scripts folder and added the following bundle

bundles.Add(new ScriptBundle("~/bundles/sharepoint").Include(

“~/Scripts/sharepoint/*.js”));

But one file i sis missing in the nugget package SP.UI.Dialog.js (which allows you to display notification bars and toasts) and that file still depend on MicrosoftAjax.js( because of Type.RegisterNamespace…)

I really think it’s only a matter of time before we have an update for the nugget package including a new version of SP.UI.Dialog.js, but in the meantime I had to copy MicrosoftAjax.js and SP.UI.Dialog.js from an old tenant (or on prem farm) and add it to my web application.

Let’s hope this post saves you time and will allow you to update your applications before you hit the problem.


Last edited Apr 15, 2024 by Vincent Biret


Tags: