AnsweredAssumed Answered

Using JSOM in Nintex Forms for O365

Question asked by aprince on Feb 13, 2015
Latest reply on Feb 27, 2015 by jjcleves

I'm following the post here: Nintex Forms O365 - Getting SharePoint ClientContext Do's and Dont's .

 

The post states to NOT load the SP.js script in your own code. Following the guidance there, the console throws an error
Uncaught ReferenceError: SP is not defined

 

If I do however load the SP.js script in my code, the error goes away but throws another error from the sp.js file:

Uncaught TypeError: Cannot read property 'isNullOrUndefined' of undefined

 

code below:

NWF.FormFiller.Events.RegisterAfterReady(function (){
  loadScripts().done(function(){
       getDataFromSharePoint();
  });
})


var appwebUrl = NF.Url.getQueryStringParameter("SPAppWebUrl");
var hostUrl = NF.Url.getQueryStringParameter("SPHostUrl");


function loadScripts(){
  var def = NWF$.Deferred();
  var layoutsPath = "/_layouts/15/";
  var scriptsPath = hostUrl + layoutsPath;


  (function(){
       return NWF$.cachedScript(scriptsPath + "sp.js");
  })()
  .done(function(){
       def.resolve();
  })
  return def.promise();
}     


function getDataFromSharePoint(){
  var clientContext;
  var factory;


  clientContext = new SP.ClientContext(appwebUrl);
  factory = new SP.ProxyWebRequestExecutorFactory(appwebUrl);
  clientContext.set_webRequestExecutorFactor(factory);


  var web = clientContext.get_web();
  var list = clientContext.get_web().get_lists().getByTitle("Potential Projects");
  clientContext.load(list);
  clientContext.executeQueryAsync(function(){
       console.log(list);
  },
  function(){
       console.log('fail')
  });
}

 

Does anyone have any success with JSOM on Nintex Forms on O365?

What am I doing wrong?

 

Thanks,

-Aaron

 

Edit: formatting

Outcomes