Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Changing custom project field value in OnUpdating event

$
0
0

Hi everbody,

I need to update a project custom field every time a project is saved from PWA on Project Server 2010. My idea was to implement a project OnUpdating event handler that modifies the project dataset before it is saved in the DB but it seems the changes do not have any effect on the project.

Here is my code:

public override void OnUpdating(PSContextInfo contextInfo, ProjectPreEventArgs e)
        {
            Guid customFieldGuid = new Guid("xxxxxxxxxxxxxxxxxx");

            for (int i = 0; i < e.ProjectDataSet.ProjectCustomFields.Count; i++)
            {
                if (e.ProjectDataSet.ProjectCustomFields[i].MD_PROP_UID == customFieldGuid)
                {
                    e.ProjectDataSet.ProjectCustomFields[i].FLAG_VALUE = true;
                    break;
                }
            }
            e.Cancel = false;
        }

As you can see the code is quite short and it seems to work. If I debug it and look at the dataset in Visual Studio I can see the changed custom field value but the value is still not saved to the DB. Is what I am trying to do here even possible? Did I forget something important? What is the preferred way to do what I am trying to accomplish?

Thanks in advance,

Michael



Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>