setting an EPM custom field from code

R

rob.clarke

Hi, anyone have any ideas on how to set an EPM custom field via code
in the Project Client.

I've created a program that starts project and enters the values into
it, but I can't see how to put the custom values into the dialogue.

I know I don't necessarily need to run the dialogue, and can probably
use the CustomFieldProperties method, but am unsure as to the syntax.

Any ideas gratefully received.

Thanks
 
K

Kurt Verhaegen

Hi Rob,
Depending on the version 2003/2007, for 2003 you can use something like
activeproject.tasks(1).enterprisetext1 = "abcdef".
For 2007 you don't have the concept of enterprisetext1, but you have to work
with the names of the fields, so
activeproject.tasks(1).getfield(application.fieldnametofieldconstant("yourfieldname",pjtask)) = "abcdef"
The above code is VBA, and for task enterprise fields.
Grtz
Kurt
Exerti
 
R

rob.clarke

Thanks Kurt, I was trying to put an enterprise project custom field
(not a resource custom field) - but your syntax got me going in the
right direction and I now have it working.
 
R

rob.clarke

Thanks Kurt, I was trying to put an enterprise project custom field
(not a resource custom field) - but your syntax got me going in the
right direction and I now have it working.

As requested, here is the the code I used to do it. Note that using
pjTask works even though its a summary project! (see web references
elsewhere)

oProject = new Project.Application();
oProject.FileNew(false,"", false, false);
msProject = oProject.ActiveProject;
msProject.ProjectSummaryTask.SetField(oProject.FieldNameToFieldConstant("Fieldname",
Project.PjFieldType.pjTask), "Your Value");
 
Top