Tuesday, October 23, 2007 8:47 PM
chrisfie
Sample Code to Update a Resource’s Custom Field
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: }