没有通过JSOM PS.ProjectContext get_projects获得任何项目

问题描述 投票:0回答:1

Microsoft Project Server Web应用程序中我试图使用JSOM获取项目列表。

我正在遵循这些示例中的代码:

这是我要测试的内容:

var projectContext = PS.ProjectContext.get_current();
var projects = projectContext.get_projects();
projectContext.load(projects, "Include(Name)");
projectContext.executeQueryAsync(IterateThroughProjects, handleError);

function IterateThroughProjects(response) {
    var enumerator = projects.getEnumerator();
    var i = 0;
    while (enumerator.moveNext()) {
        i++;
        var project = enumerator.get_current();
        console.log("Name: " + project.get_name());
    }
    console.log("Done. " + i + " projects found.");
}

function handleError(sender, args) { 
    console.log("Request failed: " + args.get_message()); 
}

脚本运行无任何错误,但结果始终为完成。找到0个项目。即使PWA中有已发布的项目,也是如此。

这是我从服务器获得的响应:

[
    {"SchemaVersion":"15.0.0.0","LibraryVersion":"16.0.4756.1000","ErrorInfo":null,"TraceCorrelationId":"fcde4d9f-9755-2050-31d1-da0833d8ce31"},
    362,
    {"_ObjectType_":"PS.ProjectCollection", "_Child_Items_":[]}
]

我已尝试对Project OnlineProject Server 2013Project Server 2016

我缺少SharePoint或PWA中的任何设置吗?任何有相同问题的人吗?

csom project-server sharepoint-jsom project-online
1个回答
0
投票

我的问题是我正在从SharePoint App运行此代码,并且app manifest不包含项目的[[permissions(http://sharepoint/projectserver/projects-> Read):

<?xml version="1.0" encoding="utf-8"?> <App xmlns="http://schemas.microsoft.com/sharepoint/2012/app/manifest" ...> <Properties>...</Properties> <AppPrincipal>...</AppPrincipal> <RemoteEndpoints>...</RemoteEndpoints> <AppPermissionRequests> ... <AppPermissionRequest Scope="http://sharepoint/projectserver/projects" Right="Read" /> </AppPermissionRequests> </App>
添加权限后,我将获得项目列表。
© www.soinside.com 2019 - 2024. All rights reserved.