Question

I am trying to load the project context in order to access some data. I am using the SP.SOD.loadMultiple function as follows:

SP.SOD.loadMultiple(['sp.core.js', 'sp.runtime.js', 'sp.js', 'ps.js'], DoSomething());

function DoSomething() { alert('x'); }

If I remove 'ps.js' everyting works fine, but I won't be able to access project context.

I've checked and the file exists in the server: server_address/PWA/_layouts/15/ps.js

Someone knows what may be the problem here?

Thanks

Was it helpful?

Solution

Function LoadMultiple has the following signature:

function LoadMultipleSods(keys, fn, bSync)

where the first argument accepts the array of SOD keys, RegisterSod function is used for registering JS function.

Most probably in your case the registration of ps.js library is missing. In order to load ps.js library it has to be registered first and then could be loaded as demonstrated below:

SP.SOD.registerSod('SP.ClientContext', SP.Utilities.Utility.getLayoutsPageUrl('sp.js'));
SP.SOD.registerSod('PS.ProjectContext', SP.Utilities.Utility.getLayoutsPageUrl('ps.js'));
SP.SOD.loadMultiple(['SP.ClientContext', 'PS.ProjectContext'], function(){

   console.log('sp.js has been loaded..');
   console.log('ps.js has been loaded..');

});
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top