Adding Timephased Actual Work through the PSI

Brian Smith

2 Feb 2007 3:28 PM

There is some great content in the SDK on statusing (search for SubmitStatus and UpdateStatus) and even more coming soon. One of the missing pieces just at the moment is around adding timephased data. So here is a very brief example. See the SDK for better examples of programmatically building the XML – but the key piece is the format of the XML passed to the statusing.UpdateStatus web service. In my example I have a 5 day task assigned to me starting next Monday – and I want to update the actual work in my tasks to show 8h on Monday the 5th and 8h on Wednesday the 7th. The XML for this change is as follows:-


<Proj ID="a3349ba9-7eb8-4921-9024-483d0a732f1a">

<Assn ID="dd6a2aa8-b754-48b5-a6fe-b5cd50cea19b">

<PeriodChange PID="251658250" Start="2007-02-05T08:00:00" End="2007-02-05T17:00:00">480000</PeriodChange>

<PeriodChange PID="251658250" Start="2007-02-07T08:00:00" End="2007-02-07T17:00:00">480000</PeriodChange>





· a3349ba9-7eb8-4921-9024-483d0a732f1a is my Proj ID,

· dd6a2aa8-b754-48b5-a6fe-b5cd50cea19b is my Assignment ID

· The PID 251658250 means s_apid_actual_work (or Actual Work – from PSLibrary.AssnConstID.s_apid_actual_work – see SDK for more details of these constants)

· Start and End time format is critical – the ULS logs are good at giving help when you get a LastError=StatusingInvalidChangelist Instructions exception.

· 480000 = 8 hours

So executing the statusing.UpdateStatus(changeXml); where the changeXml is the same as presented above will do exactly the same as entering the two lots of 8hrs in through PWA. Tuesday will be updated to 0h planned work (because I have entered actual work for Wednesday) – and 8h will be pushed back to next Monday.

A quick pointer would be to check your XML for your changelist and confirm you have a valid PID and are using the correct parameters – it says you don’t have a PID attribute declared. I can’t enter in to a long support incident via my blog but hopefully this will give you some clues as to where to look.

Hi Brian,

thank you very much for this helpful information. Updating actual work for work resources works fine.

But updating actual costs (s_apid_actual_cost) for cost resources throws an GeneralUnhandledException SoapException.


<Proj ID="28906dc6-ae04-4238-ad4a-b2eea703ee6d">

<Assn ID="111afc47-984b-4d2e-8470-714cb9eb2084">

<PeriodChange PID="251658263" Start="2007-03-19T08:00:00" End="2007-03-19T17:00:00">7025</PeriodChange>




In our tests we are using the ChangeXML and we are logging in as FarmAdmin for our tests but we always get these kind of rights issues. Do you have any pointers for me?

"The request failed with HTTP status 401: Unauthorized.","Could not set statusing data for "RALLS KIM" on project "ABCTEST"."

Actually figured part of this out. We must run our Serivce as an Administrator to Project Server. Not sure why yet, but definitely a rights issues somewhere.

Brian, In your example above, where does the start/end time come from? If it’s the working hours for the employee, how do you retrieve that info? What if the employees work hours are 9-6 and he/she works 3 hours for would the time be 9-12? Another question. What if the employee puts 4 more hours for day? Would the total be 7 of 4 work hours. If 4, any way to increment so it shows 7?

This works great as long as I’m trying to update my own time. Is there a way to update time for others? I have full admin rights to Project Server 2007, but it looks like I need to dig into Impersonation to be able to put time into other resources Tasks page? Yes John, you will need to use impersonation to do this. See the SDK for details.

Is there an equivalent way to update cost information for cost resources? I don’t see a PID value for costs, but it doesn’t seem appropriate to enter "work" values for a cost resource.

· Ken Henderson

5 Aug 2008 9:36 PM

Hi Brian,

Thanks for posting a simple example of the changeXML structure.

I have constructed one almost identical to it but it is throwing an exception: StatusingInvalidChangeList.

Could it also throw that if I were not the assignment owner on the assignment it is trying to change (via the SetAssignmentWorkData(changeXML) method.

Or would being the wrong user generate a different exception.

The changeXML is:


<Proj ID="0A6F67D0-283E-44EB-93B0-1A594F017670">

<Assn ID="70B8AD54-D19C-41E4-937E-5EDE442D159C">

<PeriodChange PID="251658250" Start="2008-03-21T08:00:00" End="2008-03-21T17:00:00">60000</PeriodChange>




Surely, the case of the GUIDs doesn’t matter, does it?

Thanks for your help!

FYI – the following is the C# code used to produce the above changeXML string:



string actStart = "2008-03-21" + "T08:00:00";

string actEnd = "2008-03-21" + "T17:00:00";

uint actual = PSLibrary.AssnConstID.s_apid_actual_work;

uint remaining = PSLibrary.AssnConstID.s_apid_remaining_work;

StringBuilder changeXml = new StringBuilder();

changeXml.AppendFormat("<Changes>", ProjID);

changeXml.AppendFormat("<Proj ID=\"{0}\">", ProjID);

changeXml.AppendFormat("<Assn ID=\"{0}\">", AssnID);

changeXml.AppendFormat("<PeriodChange PID=\"{0}\" Start=\"{1}\" End=\"{2}\">{3}</PeriodChange>", actual, actStart, actEnd, ActWorkValue);




return changeXml.ToString();