Cascade Skyline - with Microsoft Logo and Project Support header - author Brian Smith

To Add or Update - That is the Question. The PSI and custom fields - Updated

To Add or Update - That is the Question. The PSI and custom fields - Updated

Rate This
  • Comments 46

This posting was inspired by a support call concerning custom fields - but does apply to other entities in the Project dataset and others.  The question was around the QueueUpdateProject and QueueAddToProject web services calls that are part of the Project web service in the PSI.  If you use the wrong call then the error message is usually helpful telling you you can't add with the update call and vice versa.  But the thing that does catch people out are the custom fields... 

By default a project dataset will not contain any rows in the ProjectCustomFields data table unless they have either been set (through PWA, Project Professional or the PSI) or they contain formulae, or are based on a lookup table with a default value defined.  So for a freshly created project (from Project Professional) when looking at Project Information it appears that all custom fields are there - and some may even look to have values (number fields will show 0) whereas in fact once saved there are no rows in the dataset for project custom fields (except as mentioned above - formulae based, and default lookup tables values).  So if you want to set a custom field via the PSI your code should check if there is a row already present for that custom field (identify by the MD_PROP_UID or MD_PROP_ID) and if it is there then you can change the value and use QueueUpdateProject - and if it doesn't exist then you will need to create a new blank project dataset and add a new project custom field row and set the values (including a new GUID for CUSTOM_FIELD_UID, the projects PROJ_UID and the MD_PROP_UID for the field you want to set) then use the QueueAddToProject.

(Update - Although this logic holds true for adding/updating tasks to a Project dataset you can in fact ADD a new custom field row to an existing project dataset and use the QueueUpdateProject method - and it will work.  You do not need to use the QueueAddToProject method - although this will work too, assuming it only contains the additional custom field row!  Thanks to Martin for pointing this out - through experience.)

Just to confuse the situation we have a bug currently when using the PSI or creating an Activity Plan/Proposal that can duplicate custom field rows.  If you have any project level custom fields that use graphical indicators but do not have formulae then you can get duplicate custom field rows created for each of them.  I'm not sure yet if the bug is they get created at all (as they do not get created in Project Professional projects) or that they appear twice. I will post an update when I have more information.  For now a quick workaround is to not use graphical indicators for this type of field.  Cleaning up existing ones may be a little more challenging and I would suggest a support call.  Although this causes problems for the PSI when updating these duplicated rows (so this affects changes for Activity Plans , Proposals and use of the Edit Project Properties in PWA) you can still make changes in Project Professional through the Project Information dialog.

The errors you might see - (these are generic so you could see these errors for other root causes):-

When updating a custom field for an Activity Plan or Proposal you will get an error dialog box:-

Windows Internet Explorer
An error has occurred when saving your project to the server. Please contact your system administrator for assistance.
[GeneralUnhandledException]

When updating a custom field through Project Center's Edit Project Properties option the error will display at the top of the page in red:-

The project could not be saved due to the following reason(s):

An unknown error has occured (occurred is mis-spelled in the error).

When updating through the PSI this will result in a GeneralUnhandledException.

One final point - setting or updating a project custom field for an existing Project Professional created project through the PSI or Edit Project Properties will also introduce this problem.  The extra duplicates will get added as well as the custom field you are setting.

Leave a Comment
  • Please add 7 and 1 and type the answer here:
  • Post
  • This is probably my incident :), its nice to see that mictosoft working on my issues.

    If not you should contact Valdemar Spinola SRZ070420000436

  • Thanks for the feedback Martin - and yes, I am working with Valdemar on this issue.

    Best regards,

    Brian.

  • one of the question related to Custom fields was how to remove row from custom fields dataset, when I use the Multiselect list each selected item is represented by one row. And i need to now haw to remove row when user uncheck item.

  • I've passed this information back to Valdemar - but in case this can get to you quicker, and for general readers - the answer is to use the Delete() method on the ProjectCustomFeilds row you wish to remove, then use the QueueUpdateProject method to commit the update.  So the code would look something like:-

    Check out project and read dataset

    Some code to identify the row you want to remove (the "i"th row in the example given below)

    projectDataSet.ProjectCustomFields[i].Delete();

    Use QueueUpdateProject on the dataset then check in.

  • This way i can remove row on the client but not on the server.

    PS I didn't try to remove row from multiselect list box.

  • Buy the way Project 2007 SDK should be updated, there should be note that in case that you need to ADD , REMOVE  or UPDATE custom property. You should modify the ProjectFustomFields dataset on the client and then use  QueueUpdateProject.

  • The PSI ONLY acts on the server, but I'm not sure I follow what you mean by "client".  The Project Professional client should see any changes once you have completed the QueueUpdateProject and checked in - the next time you open the project.  I have tested this method both with multi value fields and also single value fields.

    Are you meaning you wish to remove a row from the server list of custom fields?  In this case you need to use the CustomFields or LookupTable web services - but the logic should be the same.

  • Thanks for the feedback Martin.  You can also add content to the MSDN version of the SDK by clicking the Add new Community Content option on any page.  We do try to make the articles as accurate and complete as possible - but I am sure we will continue adding new examples as we find these gaps.

  • Brian,

    I had a query. How do I delete all project custom fields that I have defined using PSI leaving one column? Request your help

    I am trying to use the method below but even after check-in, it is showing me the values.

    --------------------------

    foreach (DataRow drCustomField in projectDs.ProjectCustomFields.Rows)

    {

                                        WebSvcProject.ProjectDataSet.ProjectCustomFieldsRow trCustomFieldToDelete = (WebSvcProject.ProjectDataSet.ProjectCustomFieldsRow)drCustomField;

                                        Guid YtdGuid = new Guid();

    YtdGuid = (Guid) drProjectCustomFieldRow[0]["CUSTOM_FIELD_UID"];

    if (trCustomFieldToDelete.CUSTOM_FIELD_UID != YtdGuid )

    {

    //Call Queue Delete from Project Method

                                           project.QueueDeleteFromProject(jobId, sessionId, trCustomFieldToDelete.PROJ_UID, new Guid[] { trCustomFieldToDelete.CUSTOM_FIELD_UID });

                                           System.Threading.Thread.Sleep(2000);

    }

    }

    jobId = Guid.NewGuid();

    //Call Update Project Method

                                   project.QueueUpdateProject(jobId, sessionId, projectDs, false);

                                   System.Threading.Thread.Sleep(2000);

    }

    catch (Exception ex)

    {

                                   MessageBox.Show(ex.Message);

    }

    finally

    {

                                   project.QueueCheckInProject(jobId, projectId, true, sessionId, SESSION_DESCRIPTION);

    jobId = Guid.NewGuid();

    }

  • Hi Sharat,

    To remove the custom field you need to use the Delete() method on the row in the dataset, and then use  QueueUpdateProject to persist this deletion back to the database.

    Brian.

  • I'm having some problem during executing QueueAddToProject with the project changes.

    The only change is add a new assignement for an existing Task and an existing Resource.

    I catch always the same exception ProjectSchedulingEngineException; in this link http://msdn2.microsoft.com/en-us/library/websvcproject.project.queueupdateproject.aspx says that if you change the property TASK_OUTLINE_LEVEL of a task the project server could throw an ProjectSchedulingEngineException.

    Of course I check the task and the property TASK_OUTLINE_LEVEL was the same, and this task is never been updated.

    I need some help, please email me: gabal@asm.es thanks

  • Hi Brian,

    I have few questions regarding Enterprise Custom Fields

    1. I have lot of custom fields of "project entity" type defined, is there any option to import these custom fields every time I create a project. Note that these custom fields are just text,numerical fields without any formulas.

    2. I have created few "project entity" custom fields which use formulas and show the data. Now my question is "Is there a way to check whether my formula is working?" This is possible for "task entity" custom fields but not "project entity" custom fields. In project professional you can create a temporary task level field, check whether it is working and then can copy the same to enterprise level "task entity" custom field, but for "project type" custom field there is no such facility...Please help

    Thanks in advance,

    ~Shreenivas

  • Hi Shreenivas,

    I am not sure I follow the first question. Do you want to set the fields for each project?  You could use the OnCreate event for projects and do this via code.  Or do you mean that you want to see the fields in the dataset of newly created projects?

    For the second question perhaps you could use the Project Summary task (Task 0) to test your formulae.  The project and task entities are very similar.

    Best regards,

    Brian.

  • Thanks for the reply. It helped a lot.

  • Hi Brian

    I am trying to update a Custom Field [which was already added thru PWA] in a project through QueueUpdateProject.

    Steps I Did -

     - Got the project dataset from the working store

     - Updated the custom field value in ProjectCustomFields table.

     - Update the project QueueUpdateProject. Wait for completion

     - Check In the project and wait for completion

     - Publish the project.

    But everything goes through well but the data is not getting updated in PWA.

    If I give DataSet.AcceptChanges() before calling QueueUpdateProject, I get an error - CustomFieldRequiredValueNotProvided [Captured thru PSClientERR]

    Please advice what could be wrong

    Thanks

    Yuvaraj

Page 1 of 4 (46 items) 1234