Update Enterprise Custom Field Value using PSI in Project Server

In this post, we will learn how to Update Enterprise Custom Field Value using PSI in Project Server.

You might also like to read PSI Exception : The HTTP request is unauthorized with client authentication scheme ‘Anonymous’ in Project Server


Update Enterprise Custom Field Value using PSI in Project Server

In Project Server, when I tried to update a custom field value for specific project using PSI web service. I got the following exception

ProjectServerError(s) LastError=CustomFieldInvalidTypeColumnFilledIn Instructions: Pass this into PSClientError constructor to access all error information

Update Enterprise Custom Field Value using PSI in Project Server

This exception specifically occurred at the below line of code:

projectSvc.QueueUpdateProject(jobId, sessionId, project, validateOnly);

Cause

This problem might occur if the custom field type is not matched with the assigned value.

For example, if you tried to update a text data type custom field with a date or number value, you will get this error because the field datatype must be matched with the data assigned.

Solution

The below steps would help to trace this exception and solve it:

  • First of all, you can check the Project Server Error Code from this link.
  • As per the Project error code list, I got that I updated a custom field value with an invalid value.
    • The values type should fall in the following types:
      • (DATE_VALUE).
      • (TEXT_VALUE).
      • (DUR_VALUE).
      • (CODE_VALUE).
      • (FLAG_VALUE).
      • (NUM_VALUE).
  • I checked the custom field data type that I need to update it, by doing the following:
    • Go to Project Server setting:
Project Server Setting
  • Below “Enterprise Data” -> Click “Enterprise Custom Fields and Lookup Tables“.
Enterprise Custom Fields and Lookup Tables
  • Find the required custom field > Below type column check its type.
  • As shown below, the custom field type is Text!
CustomFieldType
  • Go back to the code, and check what’s the assigned value type that you were using
    • In my case, I used the type as DATE_VALUE! that must be TEXT_VALUE.
  • The final code must be as the following:
if (row.MD_PROP_UID == LastHijriUpdatedDate)
 {
 //if yes, write it into the container
 System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("ar-SA");
 row.TEXT_VALUE = DateTime.Now.Date.ToString();
 //and set the indicater
 updatedatacount += 1;
 }

Conclusion

In conclusion, we have learned how to Update Enterprise Custom Field Value using PSI in Project Server

Applies To
  • Project Server 2013.
  • Project Server 2010.
See Also

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top