cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nintex Form for office365 hangs with loading symbol

Hi,

In office365\SharePointOnline environment on a custom list (say the list name is A)Nintex form, I referenced external JS file and wrote some script using Jquery\Rest ApI to fetch data from different listB, so that I can hide a Repeating section on listA, based on value from ListB. The below script executes perfectly on List A i.e. gets the data and hides the control in question. But, the form, ListA Nintex form is stuck on loading symbol for long time and never finishes (Screen Shot attached) .

Custom Script in Fetch.js(Executes on Form load of ListA)

var spHostUrl;
var appWebUrl;
 
$(document).ready(function() {
spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    appWebUrl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
   
    var scriptBase = spHostUrl + '/_layouts/15/';   

   
     $.getScript(scriptBase + "SP.js", function() {
      $.getScript(scriptBase + "SP.RequestExecutor.js", getEmployeeDept);
     });      
   
});


function getEmployeeDept() {

var executor = new SP.RequestExecutor(appWebUrl);
    var url = appWebUrl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('ListB')/items?@target='" + spHostUrl + "'&$select=Exempt";   
   
    executor.executeAsync({
    url: url,
    method: "GET",
    headers: { "Accept": "application/json; odata=verbose" },
    success: function (data) {
      var jsonObject = JSON.parse(data.body);
      var isExempt = jsonObject.d.results[0];           
         if(isExempt)
         {
             NWF$(".rptSection").hide(); 
         } 
      },
    error: function (data, errorCode, errorMessage) {
       console.log("Unable to fetch records." +errorMessage);
    }
  });

}

I referenced files in Form-Setting -- Advanced -- Custom javascript
includes as below:-

https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.min.js

https://mySharepointSite/SiteAssest/Code/JS/Fetch.js

So, how to get away with this issue of form hanging? Is there a way to force further execution once my above script executes?

Thanks,

0 Kudos
Reply
1 Reply
Not applicable

Re: Nintex Form for office365 hangs with loading symbol

Fixed by wrapping the script in to NWF.FormFiller.Events.RegisterAfterReady, to ensure script is executed after nintex form loads

var pollSP; 
NWF.FormFiller.Events.RegisterAfterReady(function (){ 
    pollSP = setInterval(checkSPLoad, 500); 
}); 
     
function checkSPLoad(){ 
    if (clientContext){ 
        window.clearInterval(pollSP); 
        onSPLoad(); 
    } 
}
//$(document).ready(function()
function onSPLoad() {
spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    appWebUrl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    //Build absolute path to the layouts root with the spHostUrl
    var scriptBase = spHostUrl + '/_layouts/15/';   

    //Cross-site calls  
     $.getScript(scriptBase + "SP.js", function() {
      $.getScript(scriptBase + "SP.RequestExecutor.js", getEmployeeDept);
     });      
   
}

0 Kudos
Accept as Solution Reply