What modifications need to be made the following code to have it update multiple Custom Fields in one pass. I have everything working up until the point I want to start updating multiple Custom Fields. The current program I’ve put together only results in updating the first ForEach cfValueWOD Custom Field. I can get the code to update multiple fields if they already have a value but for my project these custom fields can either have an initial value or no value to start. In both cases I will need to write values to these fields. I need to complete this for a project at work very soon and I’m at a loss. Your help will be much appreciated.
Guid myProjectUid = new Guid("{c96bd7ea-e9d2-47ed-8819-02e4653e92a7}");
ProjectDataSet myProject = projectSvc.ReadProject(myProjectUid, DataStoreEnum.WorkingStore);
bool customFieldFound = false;
foreach (ProjectDataSet.ProjectCustomFieldsRow cfRow in myProject.ProjectCustomFields)
{
if (cfRow.MD_PROP_UID == cfIdWOD)
{
cfRow.TEXT_VALUE = cfValueWOD;
customFieldFound = true;
}
}
if (!customFieldFound)
{
ProjectDataSet.ProjectCustomFieldsRow cfRowWOD =
myProject.ProjectCustomFields.NewProjectCustomFieldsRow();
cfRowWOD.SetDATE_VALUENull();
cfRowWOD.SetTEXT_VALUENull();
cfRowWOD.MD_PROP_UID = cfIdWOD; cfRowWOD.CUSTOM_FIELD_UID = Guid.NewGuid();
cfRowWOD.PROJ_UID = myProjectUid; cfRowWOD.FIELD_TYPE_ENUM = 21;
cfRowWOD.TEXT_VALUE = Convert.ToString(cfValueWOD); myProject.ProjectCustomFields.AddProjectCustomFieldsRow(cfRowWOD);
}
foreach (ProjectDataSet.ProjectCustomFieldsRow cfRow in myProject.ProjectCustomFields)
{
if (cfRow.MD_PROP_UID == cfIdWG)
{
cfRow.TEXT_VALUE = cfValueWG;
customFieldFound = true;
}
}
if (!customFieldFound)
{
ProjectDataSet.ProjectCustomFieldsRow cfRowWG =
myProject.ProjectCustomFields.NewProjectCustomFieldsRow();
cfRowWG.SetDATE_VALUENull();
cfRowWG.SetTEXT_VALUENull();
cfRowWG.MD_PROP_UID = cfIdWG; cfRowWG.CUSTOM_FIELD_UID = Guid.NewGuid();
cfRowWG.PROJ_UID = myProjectUid; cfRowWG.FIELD_TYPE_ENUM = 21;
cfRowWG.TEXT_VALUE = Convert.ToString(cfValueWG); myProject.ProjectCustomFields.AddProjectCustomFieldsRow(cfRowWG);
}