As I get further and further into the Project Server Interface (PSI), I run up against gaps in my knowledge and some times the community's knowledge, as it exists in searchable form online. This little "gotcha's" can sometimes mean hours of research and experimentation. I thought I would start a new series entitled "It's the Little Things" to capture some of this knowledge. It would be great if others would chip in so send me your little tips and tricks and I will catalogue them here.
So, for the first of the series, let me tell you a story about timesheets.
I am working on a project to populate current timesheets with timesheet lines from the previous timesheet. The population is done in the timesheet OnCreated event.
Let's take a look a the code:
When I first started working on this, I didn't set the ASSN_UID field because I don't have an assignment GUID--it isn't a timesheet line for an assignment. PrepareTimesheetLine was bombing. The key is to properly set TS_LINE_VALIDATION_TYPE = TimesheetEnum.ValidationType.Unverified.
This indicates to the API to ignore the missing ASSN_UID in calls to both PrepareTimesheetLine and QueueUpdateTimesheet.
Because I had been staring at the timesheet user interface in PWA, where the word "unverified" showed up on timesheet lines that weren't associated with tasks, I assumed setting the validation type was simply cueing the rendering engine to display "unverified" versus what it was really doing: telling the validation engine to consider the timesheet line unverified thus ignoring the lack of a GUID on the ASSN_UID field. Duh!
Its the little things...