简体   繁体   中英

How to change the value of a custom field in Project Server 2013 (C# VSTO AddIn)

I am trying to update/change an enterprise custom field of a project from within a MS project plugin written in C#. I found information on how to update an enterprise custom field on task or resource level:

MSProject.Task t = ....;
t.SetField(Application.FieldNameToFieldConstant("xyz"),"value");

But I simply cannot find any documentation or examples of how to do that for a custom field on the project level.

Maybe I am just using the wrong search phrases. I tried to google different key words like project header field and similar words as well, but found nothing.

I am inclined to think that maybe it is not possible?

After hours of searching I finally found the solution. It is actually really simple once you know how it is done.

The project has a summary task which has all the custom fields of the project.

MSProject.Project proj = ...;
var field = proj.Application.FieldNameToFieldConstant("field_name", MSProject.PjFieldType.pjProject);
proj.ProjectSummaryTask.SetField(field, "value");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM