If you have poked around VBA in Project Professional 2007 you may have noticed that there is not what I would call "direct" object model access to the enterprise custom fields you create in Project Server 2007. For one thing these fields are not like they were in Project Server 2003. In 2003 you got 30 Outline Code fields and you renamed them but via VBA you still accessed the field as OutlineCodeXX. In 2007 you create enterprise fields 'from scratch.' They are not just renamed fields. They are new fields. The object model is not dynamic in a way that allows it to add new members as they are created. This means that you cant just get to a field by the old method: Activeproject.Tasks(1).OutlineCode1.
To access an Enterprise Task field called "Task Alignment" you would use the following code:
Activeproject.Tasks(1).GetField(FieldID:=Application.FieldNameToFieldConstant(FieldName:="INSERT FIELD NAME),FieldType:=pjTask)
You use the GetField method. This method requires the FieldID. To get the FieldID (since it is unlikely you know it) you use the FieldNametoFieldConstant method.
I am trying to do the same with Enteprise Project (i.e. NOT Task) Custom Fields.
Which way can I access and read them?
Posted by: Luca | Tuesday, June 24, 2008 at 03:13 AM
This is a great start for me, but I wonder if you can tell me if it is possible (and if so, how), to generate a list of all the Enterprise Fields that are read only? It's kind of a catch 22 where I need to know all the names of the fields to be able to reference them, but I have a code requirement to be able to search for all Enterprise fields without knowing their name (incase the list changes, I don't want to have to specifically name them in my code) - Hope this makes sense, and you can help. Cheers
Posted by: Ross | Thursday, January 10, 2008 at 02:44 PM