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 49

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 5 and 1 and type the answer here:
  • Post
  • Not sure if this could be a related issue: I have a Master Project with two SubProjects. I have an enterprise Custom Field (resource) with a Lookup Table, called "Cost Type". I created a View containing this field and Grouped on it. It worked fine for the first subproject. I made some resource edits in the second subproject and tried to use the same view on it and on the master project, but at this point all the custom field data was gone. Each individual project still shows all the right data in this custom field, but now when I open the View the grouping is gone and there is apparently no data coming through on the custom field into the view.

  • HiYuvaraj,

    These appear to be the right steps.  If you do it through PWA does it work?  Or if you re-read the dataset from the working store is the modified data there?

    Best regards,

    Brian

  • Hi Brian

    Thanks for the reply

    I am able to do it with PWA.

    For now, i created a new PWA and there it is working fine.. not sure what was the issue though...

    Regards

    Yuvaraj

  • Hi Moritz

    I had done some debugging on the custom fields with views. What happens is each time you update the custom fields, the in built views[like MSP_PROJECT_USERVIEW] which uses the custom fields get's re created with the updated data[the existing field information also might change], So if you are using your custom views the new data may not updated automatically. This could be the problem

    Brian, Correct me if I am wrong :)

    Thanks

    Brian

  • Hi Brian

    Sorry for flooding your blog three times in a day :)

    I have another issue now, I have added a custom event handler to the Project Check In event, but everytime when the event is raised i get the following error in the eventlog

    Event Type: Error

    Event Source: Office SharePoint Server

    Event Category: Project Server Server-Side Events

    Event ID: 7696

    Date: 8/31/2007

    Time: 11:46:24 AM

    User: N/A

    Computer: 51787

    Description:

    Standard Information:PSI Entry Point:

    Project User: DomainName/Yuvaraj_C

    Correlation Id: ab718b41-3660-4e5f-8972-3f5e8a0818a8

    PWA Site URL: http://51787:32311/PWA

    SSP Name: SharedServices1

    PSError: GeneralActionCanceledBecauseServerEventServiceProblem (22002)

    Action cancelled because of a problem with the Project Server Event Service.

    Event that was cancelled: ProjectCheckIn.

    the event handler also is not executed

    Went through this article , http://msdn2.microsoft.com/en-us/library/ms508961.aspx, but the solution to this is not given there

    Got the log file with me, but could not attach it here...

    Please advise what could be wrong

    Thanks a Lot

    Yuvaraj

  • Thanks for responding Yuvaraj - I think you are on the right tracks - not sure if a re-publish will flush everything through to the new view.

    Brian.

  • Re-publishing the projects did not flush everything through to the new view. Then I tried deleting the projects completely (although I did not delete the custom field) and re-saved/re-published the projects from saved copies; this did not work either. Next I might try deleting the projects, deleting the custom field, and recreating everything. The question now becomes, is there a "correct" order that things must occur in, for this mechanism to work?

  • Hi brian

    I am trying to read the project dataset in the custom event handler after project check in event.

    But i get the following error -

    Description:

    Event Handler \CustomHandler.FieldUpdateHandler\ threw an exception: The request failed with HTTP status 401: Unauthorized.

      at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)

      at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

      at CustomHandler.ProjectWebSvc.Project.ReadProject(Guid projectUid, DataStoreEnum dataStore)

      at CustomHandler.FieldUpdateHandler.OnCheckIn(PSContextInfo contextInfo, ProjectPostEventArgs e)

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

    Clearly it shows it is due to the credentials issue. But i checked the ContextInfo.Username it is the same as my domain name and i have full privileages. by default IsWindowsUser was set to false, so I tried changing it to true before calling the web service, but still the same issue

    The same code when i run via a web service passes through fine.

    Please advice what could be the issue.

    Regards

    Yuvaraj

  • Hi Yuvaraj,

    The event handler will be running in the context of the account running the event service - which will be the account set as the administrator of the SSP.  You can see who this account is by looking at task manager.  You should see more than one task for the Event service and one will be running as the farm administrator and each other one will be running as an administrator of any SSP's defined that have PWA sites provisioned.  Of course they could all be the same user if you have it configured that way.  So one way to work is to add a user to PWA that is this user so that it can use the web services.  Another way is to use impersonation.  Either way you need valid credentials and url set for any web service you use.

    Best regards,

    Brian.

  • Hi Brian

    Thanks for the help, impersonation did the trick

    Thanks a lot

    Regards

    Yuvaraj

  • Hi Brian

    I have mapped the event handler to After check In event. In the event handler , i have to populate some custom fields based on the status of the project. For that I have checkout the project, update it  and  check in again, which triggers the check in event again. I tried OnUpdating event, but the ProjectDataset though updated does not reflect in the server. the logic is such a way that i cannot use a formula.

    Please advice how we can do this.

  • Hi Yuvaraj,

    Tricky one.  The best I can think initially is to use the PROJ_SESSION_DESCRIPTION and read this before you check the file out for your event updates.  In your code you can set this to a specific string - whereas for user edits it will have machinename\pwa_profile. If you read your string then you know you have already made the required updates and can ignore the event. One other way would be to use the PROJ_CHECKOUTDATE.  If the check-in is a result of your code then the time will be very close to the current time.  If it was checked out by a user then they will very likely have had it open for some longer period of time.  This may allow you to break the loop. The first is probably the more reliable solution.

    Brian.

  • Hi Brian

    Thanks for the info, did not know such a provision exits. Will try it out

    Regards

    Yuvaraj

  • Hi Brian,

    I would like to use TaskCustomFieldsRow to update some CF in a Project. I do not know how to do this. I have retrieved a taskRow that I want to target, but can't get to the CF fields.

    ProjectWebSvc.ProjectDataSet.TaskRow taskRow;

    taskRow = projectDs.Task.FindByTASK_UIDPROJ_UID(....

    I can update non custom fields fine and save and publish.... just can't get to the CF.

    Thanks,

    Duffman

  • Hi Brian,

    I have custom field called Expense at Task level and trying to update the value programatically. I am getting an error "CustomFieldRequiredValueNotProvided" and I checked all the other required CF and it has values. Could you please let me know how to update the value for that CF?

    Thanks in advance, GSK

Page 2 of 4 (49 items) 1234