更新任务级别的自定义字段 [英] Updating Task level custom fields

查看:103
本文介绍了更新任务级别的自定义字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CSOM,我可以看到如何使用SetCustomFieldValue方法更新与项目相关联的自定义字段,但是对于Project Online中的任务无法做到这一点吗?我看不到任何允许这样做的东西,但是它确实在文档中列出了这一点.

Using CSOM I can see how to use the SetCustomFieldValue method to update custom fields associated to a Project, but is it not possible to do this for a task within Project Online? I don't see anything that would allow this but it does list in the documentation this should be possible.

谢谢!

推荐答案

我可以给你一个JSOM示例来实现:

I can give you a JSOM example to do this:

var projContext = PS.ProjectContext.get_current();    
var projects = projContext.get_projects();
var project = projects.getByGuid(projUid).get_draft();
var tasks = project.get_tasks();

var task = tasks.getByGuid(taskUid);

task.set_item(cfIntName, newValue);

var queueJob = project.update();

projContext.waitForQueueAsync(queueJob, 60, 
    Function.createDelegate(this, function(res) {
        // Publish project here
    }), function(error) {

    console.error(error);        
}); 

那应该是完整的(尽管我是从脚本中拉出来的,所以检查一下我截断的成功/失败处理程序)

That should be complete (though I pulled it from a script, so check the success / failure handlers which I truncated)

从CSOM的内存中查找内存时,没有可使用的"set_item(cf,val)"帮助程序方法,但这很相似,我认为该属性是通过索引器在对象实例上设置的,例如:

From memory poking around in the CSOM there is no "set_item(cf, val)" helper method to use, but it was similar, I think the property is set on the object instance via an indexer, e.g.:

(sudo C#代码)

(sudo c# code)

var draftTask = [get task instance];
draftTask[cfInternalName] = "Some value";

如果这样做没有帮助,那么您始终可以反映ProjectServer.Client.DLL,并且会看到内部公开显示的"SetCustomFieldValue".

If that doesn't help then you can always reflect the ProjectServer.Client.DLL and you'll see the internal implementation of "SetCustomFieldValue" which is not publicly exposed.

希望能帮助到某人.

这篇关于更新任务级别的自定义字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆