Tuesday, December 7, 2010

Updating and Deleting Custom Fields using the PSI


to Updating and Deleting Custom Fields value using the PSI in Project Server 
 private void btnUpdateCF_Click(object sender, EventArgs e)         {             Guid taskTextGuid = new Guid("30665299-bc21-4c51-b954-220d407ba47e");             Guid projectId = new Guid("4c1cef33-4810-4159-b2e1-db15ea19a28b");             WebSvcProject.ProjectDataSet projectDs =                  project.ReadProject(projectId, WebSvcProject.DataStoreEnum.WorkingStore);              foreach (WebSvcProject.ProjectDataSet.TaskCustomFieldsRow cfRow in                  projectDs.TaskCustomFields)             {                 if (cfRow.MD_PROP_UID == taskTextGuid)                 {                     cfRow.TEXT_VALUE = "Updated Value";                 }             }             Guid sessionUid = Guid.NewGuid();               project.CheckOutProject(projectId, sessionUid, "Updating CF");             Guid jobUid = Guid.NewGuid();             project.QueueUpdateProject(jobUid, sessionUid, projectDs, false);             jobUid = Guid.NewGuid();             project.QueueCheckInProject(jobUid, projectId, false, sessionUid, "Updating CF");          }


private void btnDeleteCF_Click(object sender, EventArgs e)         {             Guid taskTextGuid = new Guid("30665299-bc21-4c51-b954-220d407ba47e");             Guid projectId = new Guid("4c1cef33-4810-4159-b2e1-db15ea19a28b");             WebSvcProject.ProjectDataSet projectDs =                  project.ReadProject(projectId, WebSvcProject.DataStoreEnum.WorkingStore);                          foreach (WebSvcProject.ProjectDataSet.TaskCustomFieldsRow cfRow in                  projectDs.TaskCustomFields)             {                 if (cfRow.MD_PROP_UID == taskTextGuid)                 {                     cfRow.Delete();                 }             }             Guid sessionUid = Guid.NewGuid();              project.CheckOutProject(projectId, sessionUid, "Updating CF");             Guid jobUid = Guid.NewGuid();             project.QueueUpdateProject(jobUid, sessionUid, projectDs, false);             jobUid = Guid.NewGuid();             project.QueueCheckInProject(jobUid, projectId, false, sessionUid, "Updating CF");         }

No comments:

Post a Comment