Update Resource Custom Field From Lookup Table Value
-
jeudi 7 juin 2012 15:55
Hi
I am trying to update a enteprise custom field in epm using the PSI web services. Here is a list of the steps that I am following. I am not getting any errors but the value is not changing. Any help would be appreciated.
1. Create a resource dataset using the ReadResource method
resourceDataset = resourceService.ReadResource(new Guid("E17E6CFB-AB62-4D24-873E-4CB2CECBC6D6"));2. Check out the resource
resourceService.CheckOutResources(new Guid[] { new Guid("E17E6CFB-AB62-4D24-873E-4CB2CECBC6D6") });3. Use a custom method that I developed to get the custom field id and other details
CustomField timesheetCaptureControlCustomField = GetCustomFieldDetails("Time Capture Control");4. Set the value of the new guid that I want the original value to be replaced with
Guid newValue = new Guid("954EF11E-F870-4DD7-9B9E-1BFE300DF8A4");5. Loop through the resource custom fields, find the custom field that I want to update, change its value to the new value and accept changes in the dataset. Then update the resource
foreach (PWAResourceService.ResourceDataSet.ResourceCustomFieldsRow resourceCustomField in resourceDataset.ResourceCustomFields) { if (resourceCustomField.MD_PROP_UID == timesheetCaptureControlCustomField.MD_PROP_UID) { resourceCustomField.CODE_VALUE = newValue; resourceDataset.ResourceCustomFields.AcceptChanges(); resourceDataset.Resources.AcceptChanges(); break; } } resourceDataset.AcceptChanges(); resourceService.UpdateResources(resourceDataset, false, true);
Like I said, I'm getting no errors but the value is not being updated.
Toutes les réponses
-
jeudi 7 juin 2012 17:20
Kirk,
Try removing the AcceptChanges lines. I have had this problem before and those lines have been the culprit.
- Marqué comme réponse Kirk De Villiers vendredi 8 juin 2012 14:25
-
vendredi 8 juin 2012 14:26Thanks Paul, I feel like such an idiot. That was the solution
-
vendredi 8 juin 2012 19:31
Don't feel like an idiot, it took me two days to figure out that problem when it happened to me :)
120811049008