Custom Field Invalid Type Column During updateing a custom field value via PSI in Project Server

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

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

CusromFieldType

This exception specifically occurred when the debug hit the following line in my 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 date or number value this will cause this issue.

Solution:

The following steps will help you to trace this exception and solve it:

  • Generally, check the Project Server Error Code from here where I checked the error code and understand that I update custom field value with an invalid value.
    • Note: the values type should fall in the following types:
      • (DATE_VALUE).
      • (TEXT_VALUE).
      • (DUR_VALUE).
      • (CODE_VALUE).
      • (FLAG_VALUE).
      • (NUM_VALUE).
  • Check the type of custom field that you need to update,
    • Go to Project Server setting:

ServerSetting

  • Below Enterprise Data -> Click Enterprise Custom Fields and Lookup Tables.

EnterPriseData

  • Find the required custom field > Below type column check its type.

CustomFieldType

  • As above shown, you could note that the custom field type is Text!
  • Go back to the code, and check what’s the assigned value type that you use
    • In my case, I used the type as DATE_VALUE! that it 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;
}

The exception should now been solved.

Enjoy 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s