Hello,
I want to change the Custom field value of Project Server 2010. I am following the brain article. My problem is the code run successfully but the changes did not reflect to the Project server. Following is my code, Any Help??
private void UpdateRecordInProjectServer(string newValue, string projGuid, string propertyToEdit){
ProjectSoapClient projectSvc = new ProjectSoapClient();
CustomFieldsSoapClient customfieldSvc = new CustomFieldsSoapClient();
CustomFieldDataSet fieldDefs = customfieldSvc.ReadCustomFields(string.Empty, false);
LookupTableSoapClient loockuptableSvc = new LookupTableSoapClient();
Guid projectId = new Guid(projGuid);
ProjectDataSet projectDs = projectSvc.ReadProject(projectId, ListProjects.Project.DataStoreEnum.WorkingStore);
foreach (ProjectDataSet.ProjectCustomFieldsRow cfRow in projectDs.ProjectCustomFields.Rows)
{
// projectDs.ProjectCustomFields.RemoveProjectCustomFieldsRow(cfRow);
CustomFieldDataSet.CustomFieldsRow fieldDefinition = fieldDefs.CustomFields.Single(
cfd => cfd.MD_PROP_UID == cfRow.MD_PROP_UID);
if (fieldDefinition.MD_PROP_NAME == propertyToEdit)
{
cfRow.TEXT_VALUE = newValue;
}
//projectDs.ProjectCustomFields.AddProjectCustomFieldsRow(cfRow);
projectDs.ProjectCustomFields.AcceptChanges();
}
Guid sessionUid = Guid.NewGuid();
Guid jobUid = Guid.NewGuid();
if (!IsProjectCheckedOut(projectId))
{
projectSvc.CheckOutProject(projectId, sessionUid, "Updating CF");
jobUid = Guid.NewGuid();
projectSvc.QueueUpdateProject(jobUid, sessionUid, projectDs, false);
System.Threading.Thread.Sleep(4000);
}
jobUid = Guid.NewGuid();
projectSvc.QueueCheckInProject(jobUid, projectId, false, sessionUid, "Updating CF");
System.Threading.Thread.Sleep(4000);
jobUid = Guid.NewGuid();
projectSvc.QueuePublish(jobUid, projectId, true, SPContext.Current.Site.Url);
System.Threading.Thread.Sleep(4000);
}
Muhammad Ali