I have a custom js that creates dynamic layout. There is a function which renders this layout consisting of multiple divs. When I debug the JS, the layout is rendered correctly but when I run it without debugging the code does not execute.
It also gives the error "The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.". I am not able to figure out what is the issue.
The function that is being called is complex. Is there any mechanism to set the delay in the execution of the JavaScript?
Please guide.
Code as given below:
var documentType;
var docLibName = "Documents";
var documentTitles;
var SiteCol_URL = window.location.protocol + '//' + window.location.host;
$(document).ready(function(){
//Custom code to get documents based on query:
SP.SOD.executeFunc('SP.js', 'SP.ClientContext', function () {
var serviceOffering = getQueryStringParameter("sf");
serviceOffering = decodeURIComponent(serviceOffering);
var docTypeArray = new Array(6);
docTypeArray = ["Framework Documents","Case Studies","Presentations","Others","Customer Literature","Pricing"]
for(var i =0; i<5;i++)
{
documentType = docTypeArray[i];
retrieveListItemsInclude(serviceOffering, documentType,docLibName);
wait(2000);
}
});
retrieveListItemsInclude. It is this function where error may be showing up.