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");