Project Custom Fields Dataset
-
11 mai 2010 19:00
I want a dataset that holds the values of custom fields. For example if I had a Project level custom field named "Project Location", I want a dataset to include the text value (such as Boston, Philadelphia, New York, etc). The code below returns only a dataset that holds the guid of the lookup field, but not the text value.. Suggestions appreciated.
private void GetAllEntities() { const int ENTITY_PROJECTCUSTOMFIELDS = 32; const int ENTITY_TASKCUSTOMFIELDS = 64; const int ENTITY_RESOURCECUSTOMFIELDS = 128; const string PROJECT_SERVER_URI = "http://natty/pwa_nwt/"; const string PROJECT_SERVICE_PATH = "_vti_bin/psi/project.asmx"; // Set up the Web service objects WebSvcProject.Project project = new WebSvcProject.Project(); project.Url = PROJECT_SERVER_URI + PROJECT_SERVICE_PATH; project.Credentials = CredentialCache.DefaultCredentials; Guid projectUid = new Guid("d96e4a2e-eae0-4ee3-9b8c-2129fc0bef1a"); //guid of an active project int entities = ENTITY_PROJECTCUSTOMFIELDS | ENTITY_TASKCUSTOMFIELDS | ENTITY_RESOURCECUSTOMFIELDS; WebSvcProject.ProjectDataSet readProjDs = project.ReadProjectEntities(projectUid, entities, WebSvcProject.DataStoreEnum.PublishedStore); }
Toate mesajele
-
12 mai 2010 03:43Proprietar
User ReadProjectEntities and ProjectCustomFieldsRow…:Foreach (ProjectRow project in readProjDs.Project)
{
//ReadProjectEntities is published here
currentProjectDS = projectSvc.ReadProjectEntities(project.PROJ_UID, 32, ProjectWS.DataStoreEnum.PublishedStore);
//Have highlighted that am looking only for published projects (it can be ‘workingstore’ if we want to lookup from Draft database).
foreach (ProjectWS.ProjectDataSet.ProjectCustomFieldsRow row in currentProjectDS.ProjectCustomFields)
{
//Check if row has been returned
If (row.length > 0)
{
//get the value of the respective field …the ProjectCustomFieldsRow members are published here
// Code can be written to create and return a data table…
}
}
}
http://blogs.msdn.com/chrisfie- Marcat ca răspuns de Christophe FiessingerMicrosoft Employee, Owner 12 mai 2010 03:43
-
12 mai 2010 04:09Moderator
You'll need to use the CustomFields methods, after you get the custom field GUID. Try CustomFields.ReadCustomFieldsByEntity2 Method.
If the custom field uses a lookup table, you'll also need to use the LookupTable methods, e.g. LookupTable.ReadLookupTablesByUids.
There are some additional examples in the Project 2007 SDK that help understand custom fields and lookup tables -- although the examples create and use a lookup table, rather than read it. See Walkthrough: Creating a Hierarchical Lookup Table.
-
12 mai 2010 15:03Thanks to all!