Working with Enterprise Custom Fields via VBA Macros in MS Project 2010 #MSProject #ProjectServer #SharePoint #SP2010 #in
As per my previous post, my colleagues and I are working on various customisations to the Microsoft Project 2010 client in our SharePoint 2010 / Project Server 2010 integration project for an international company.
Primarily my job is to architect and implement SharePoint solutions but recently I have been getting heavily involved in Project Server and Microsoft Project.
Yesterday and today I have been having to dust off my VBA skills to aid a colleague and wil the help of MSDN forums, we were able to come to a solution.
We found that when querying Enterprise Custom Task Fields from Project Server using the GetFields method, it would return them as a string value as it was shown in the client, regardless of the field type.
If you use the same GetFields method to query a local task field, it will be returned as expected in accordance to the field type.
For Example:
Client Setup Details: 1 Day = 8 Hours (480 Minutes)
Enterprise Custom Task Field
- Field Name: EnterpriseDurationTest
- Field Type: Duration
- Field Source: Enterprise Custom Task Field (Project Server)
- Value: 1 Day
- GetFields Method return: 1 Day
Local Custom Task Field
- Field Name: LocalDurationTest
- Field Type: Duration
- Field Source: Local Task Field (Microsoft Project)
- Value: 1 Day
- GetFields Method return: 480 (returned in minutes)
Now this make comparison quite hard unless you start splitting the string returned from the enterprise custom field and hard coding the number of hours that make up a day.
As a work around, Jan De Messemaeker (Project MVP), helped provide an answer:
By simply taking the output of the Enterprise Custom Task Field and placing it into a spare local field, it will do the appropriate conversion for us and we can the query the local field to to our comparison.
This blog post is simply here as a reminder for myself (future projects etc.) but also as a thank you to the growing Project Server and Microsoft Project community.