Set the value of custom field by code RRS feed

  • Question

  • Hi all, 

    I have 2 project custom fields  in my pdp, I want to set the value of the second field by code.

    whats the best way to do that?


    Thanks in advance.

    Twitter : @MShoubaki | http://jo.linkedin.com/in/mshoubaki
    Sunday, August 7, 2011 12:39 PM


All replies

  • Hi,

    Your query is very brief to understand completely.

    You can set the value of the custom field through the PSI call, that is one thing and is completely do-able. You can see this msdn documentation explaining the customfield webservice methods: http://msdn.microsoft.com/en-us/library/websvccustomfields.customfields_methods(v=office.12).aspx

    Second this is when do you want to set the value? You can extend the OnPublished event of the project server to do this job. that is based on some criteria, every time when the project published you can set the value of that custom field. For this you can see one of my blog where i have explained how to modify the OnPublished event: http://khurramjamshed.blogspot.com/2011/01/project-server-how-to-monitor-project.html

    hope this helps.

    | Khurram Jamshed | Follow my blog about Enterprise Project Management Solution | http://khurramjamshed.blogspot.com |
    Monday, August 8, 2011 12:41 PM
  • In addition to Khurrams answer, if you simply need to have a calculated field based the value of another field, you could assign a formula to this custom field (in PWA -> Server Settings where you define the custom field).

    That way you don't need PSI calls or event handlers.


    My EPM blog: Projectopolis
    Monday, August 8, 2011 7:34 PM
  • Thanks Khurram and Hans, Khurram I saw ur blog before I face this issue :) anyways, I will explain my problem with deeper details: suppose I have a PDP containing a custom field called "business owner" I choose the owner from dropdown list. then I have another field called "business owner manager" on the event of selecting the business owner i want to auto populate the "business owner manager" field ( I will get it from Active Directory) I think I have to write jQuery code, right??
    Twitter : @MShoubaki | http://jo.linkedin.com/in/mshoubaki
    Monday, August 8, 2011 10:59 PM
  • You can make it as beautifull as you like. The standard webpart doesn't support extension for creating some ajax call-back.

    So Khurram's sugestion to create an event handler that retrieves the manager from AD and uses the PSI to store it in the appropriate field would be the most straight forward solution.

    As an alternative you can create your own webpart (simular to the project fields webpart, interacting with PSI), that has some ajax callback functions to retrieve and set the manager. This way you can have an interactive interface for the user.

    Regards, J
    Tuesday, August 9, 2011 11:38 AM
  • Thanks Jeroen,

    I thought about the custom webpart idea, but I will face many problems, the most important one that is the user wont be able to modify the fields like in Projects Fields webpart, and the second problem is that I have to modify the ribbon, or add the save button to the webpart itself.

    What I am trying to do, is to add extension to the Project Fields WP. like what is done in the "PDP Customizations" in the solutions startes.

    if I could not I will move to Khurrams, way.

    If anyone still have a suggestion , its welcomed. :)

    Twitter : @MShoubaki | http://jo.linkedin.com/in/mshoubaki
    Tuesday, August 9, 2011 12:05 PM