Я пытаюсь разработать домашнюю страницу панели мониторинга для пользователей сайта SharePoint, и в качестве части этой страницы я использую AJAX для выполнения вызовов API для других списков на сайте.
В разделеВ контексте моей учетной записи администратора дочернего сайта вызовы AJAX выполняются без проблем, и JS правильно применяет HTML.
Какие разрешения потребуются пользователям для корректной работы следующего JavaScript?
function taskCheckListFill(){
callCurrentUser(function(userEmail){ //pulls the userEmail var from callCurrentUser into this function
//alert(userEmail);
var TodayDate = new Date(); //returns TodayDate var as the current Date from Date() method
var siteUrl = _spPageContextInfo.webAbsoluteUrl; //returns the current sharepoint site url
var dPeriod = TodayDate.getMonth(); //+1 as getMonth() method returns an index, thus Feb equals 1 and must add 1
var sYear = TodayDate.getYear()+1900; //+1900 brings the year back to standard readable format this JS method bases years off of starting at 1900
$.ajax({
url: siteUrl + "/_api/web/lists/GetByTitle('Month-End Task Checklist')/items?$filter=Period eq "+ dPeriod + " and Year eq " + sYear + " &$top=1000",
type: "GET",
contentType: "application/json;odata=verbose",
data: "",
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
},
success: function (data){
var sum = 0;
var jsonData = data.d.results
console.log(jsonData.length);
console.log(jsonData[0]);
console.log(jsonData[0].Area);
var step; //initializes the loop count var
//variables below represent the status count vars placed into the grph and
var tasksNotStartedCount = 0;
var tasksInProgressCount = 0;
var tasksWaitingCount = 0;
var tasksCompletedCount = 0
//loop is to go from 0 to number of items in list for EVERYONE in the specified period and year
for (step = 0; step < jsonData.length; step++){
console.log(jsonData[step].Title);
if(jsonData[step].Assigned_x0020_To_x002d_Email_x0 == userEmail){
$('#myTaskChecklistTable > tbody:last').append('<tr><td>'+ jsonData[step].Title +'</td><td>'+ jsonData[step].TaskID +'</td><td>'+ jsonData[step].Due_x0020_Date+'</td><td>'+ jsonData[step].Status +'</td></tr>')
};
if(jsonData[step].Assigned_x0020_To_x002d_Email_x0 == userEmail && jsonData[step].Status == "Not Started"){
tasksNotStartedCount ++
};
if(jsonData[step].Assigned_x0020_To_x002d_Email_x0 == userEmail && jsonData[step].Status == "In Progress"){
tasksInProgressCount ++
};
if(jsonData[step].Assigned_x0020_To_x002d_Email_x0 == userEmail && jsonData[step].Status == "Waiting on someone else"){
tasksWaitingCount ++
};
if(jsonData[step].Assigned_x0020_To_x002d_Email_x0 == userEmail && jsonData[step].Status == "Completed"){
tasksCompletedCount ++
};
//console.log(jsonData[step].Area);
};
document.getElementById("taskCheckListCount_GBSHOME").innerHTML = tasksCompletedCount + "/" + (tasksNotStartedCount +tasksInProgressCount+tasksWaitingCount+tasksCompletedCount) + " completed";
console.log("Not started count is equal to " + tasksNotStartedCount );
console.log("In Progress count: " + tasksInProgressCount);
console.log("Tasks waiting on someone else count: " + tasksWaitingCount);
console.log("Completed count is equal to " + tasksCompletedCount);
pieChartCall1(tasksNotStartedCount, tasksInProgressCount, tasksWaitingCount, tasksCompletedCount);
},
error: function (data) {
console.log(data.responseText);
}
});
});
};