微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我怎样才能设置'最大资源的 MS 项目中的单位 (%)'

如何解决我怎样才能设置'最大资源的 MS 项目中的单位 (%)'

在 MS-Project 中,我可以看到设置为 Current Max. Units (%): 的选项 100%

Field Current Max.Units (%)

我现在想通过 CSOM 修改此值并将其设置为 90%。此外,我更新了我的 NuGet 包并使用 Microsoft.SharePointOnline.CSOM 库的最新版本 (16.1.21312.12000)。

我试过的代码是:

// Get the resource
EnterpriseResource resource = GetMyResource();
projectContext.Load(resource);
projectContext.ExecuteQuery();

// load the Engagements
projectContext.Load(resource.Engagements,t => t.IncludeWithDefaultProperties());
projectContext.ExecuteQuery();

// try access first engagement
var firstEngagement = resource.Engagements.FirstOrDefault();
projectContext.Load(firstEngagement); // Fails: Value cannot be null. Parameter name: clientObject
projectContext.ExecuteQuery();
                            
// Modify engagement
firstEngagement.ApprovedMaxUnits = 90; // This Could be the "Current Max. Units (%)"
resource.Engagements.Update();
projectContext.ExecuteQuery();

// Add new engagement,and update
var engagement = new EngagementCreationinformation
{
    MaxUnits = 90,// This looks like the "Current Max. Units (%)"
};
resource.Engagements.Add(engagement); // .Add() not available
resource.Engagements.Update();
projectContext.ExecuteQuery();

这里我在检索第一个 Engagement 时收到错误 Value cannot be null. Parameter name: clientObject

然后我想创建一个新的约定,因为它没有找到。但是 resource.Engagements 属性没有文档中描述的 .Add().AddChild()https://docs.microsoft.com/en-us/dotnet/api/microsoft.projectserver.client.resourceengagementcollection?view=sharepoint-csom#methods

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。