其他用户的 SharePoint API 权限错误
SharePoint API Permissions Error for other users
我正在尝试为 SharePoint 网站的用户开发一个仪表板主页,作为此页面的一部分,我正在利用 AJAX 对 SharePoint 中的其他列表进行 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);
}
});
});
};
您可以添加用户 'Read' 权限级别,以便他们可以访问列表数据。
通过编辑 ROLES(不是分配给角色的组)的权限解决了这个问题。
需要激活的权限是"Use Remote Interfaces - Use SOAP, Web DAV, the Client Object Model or SharePoint Designer interfaces to access the Web site."
我通过导航到“网站内容”->“网站权限”->“点击权限级别”->“点击您要编辑的特定权限级别超链接”来访问这些设置。
我正在尝试为 SharePoint 网站的用户开发一个仪表板主页,作为此页面的一部分,我正在利用 AJAX 对 SharePoint 中的其他列表进行 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);
}
});
});
};
您可以添加用户 'Read' 权限级别,以便他们可以访问列表数据。
通过编辑 ROLES(不是分配给角色的组)的权限解决了这个问题。
需要激活的权限是"Use Remote Interfaces - Use SOAP, Web DAV, the Client Object Model or SharePoint Designer interfaces to access the Web site."
我通过导航到“网站内容”->“网站权限”->“点击权限级别”->“点击您要编辑的特定权限级别超链接”来访问这些设置。