none
Update Resource Custom Field From Lookup Table Value RRS feed

  • Question

  • 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.

    Thursday, June 7, 2012 3:55 PM

Answers

  • Kirk,

    Try removing the AcceptChanges lines. I have had this problem before and those lines have been the culprit.

    Thursday, June 7, 2012 5:20 PM

All replies