Sample Code to Update a Resource’s Custom Field

Christophe Fiessinger's Blog

The latest news you need to know about Microsoft Project

Sample Code to Update a Resource’s Custom Field

  • Comments 2

Please find below a code sample I wrote that updates a Resource's Custom Field of type Flag.

You can call this method in a loop for instance to automatically reset a CF for all resources.

   1:          public static bool UpdateResourceCustomField(ResourceWS.ResourceDataSet resDS, Guid cfUID, bool flagValue)
   2:          {
   3:              Guid cfExists = GetCUSTOM_FIELD_UID(resDS, cfUID);
   4:              if (cfExists != Guid.Empty)
   5:              {
   6:                  for (int cf = 0; cf < resDS.ResourceCustomFields.Count; cf++)
   7:                  {
   8:                      if (resDS.ResourceCustomFields[cf].MD_PROP_UID == cfUID)
   9:                      {
  10:                          resDS.ResourceCustomFields[cf].FLAG_VALUE = flagValue;
  11:                          return UpdateOneResource(resDS);
  12:                      }
  13:                  }
  14:              }
  15:              else
  16:              {
  17:                  resDS.ResourceCustomFields.AddResourceCustomFieldsRow(AddResourceCustomField(resDS.Resources[0].RES_UID, cfUID, flagValue, resDS));
  18:                  return UpdateOneResource(resDS);
  19:              }   
  20:   
  21:              return false;
  22:          }

 

Leave a Comment
  • Please add 7 and 5 and type the answer here:
  • Post
  • In Project Server 2007 the structure of the custom fields has changed and this is causing some confusion

  • In Project Server 2007 the structure of the custom fields has changed and this is causing some confusion

Page 1 of 1 (2 items)