Update timesheet in single entry mode RRS feed

  • Question

  • Hi,

    I'am trying to update a timesheet programmatically in single entry mode. It works in PWA but not via PSI. Entering actual work hours and non billable actual work in the PWA timesheet recalculates the planned work after saving the timesheet. There was no planned work for that task on this day.

    I would like to have this exact result also after the timesheet update via PSI. There is no PSI error for the update itself. But looking in the timesheet in PWA shows only the correct value in the actual non-billable row for the specific day. The value for the actual work is always the negative value of the non-billable work, resulting in an error in my timeheet.

    It work via PSI, if I don't use single entry mode. But that is not waht I want to do.

    Maybe I' am just missing something in my code:


    resGUID = projUtility.wsResource.GetCurrentUserUid()
          Dim timesheetListDS As TECMD.WSTimeSheet.TimesheetListDataSet = projUtility.wsTimeSheet.ReadTimesheetList(resGUID, _date, _date, Microsoft.Office.Project.Server.Library.TimesheetEnum.ListSelect.AllPeriods)
          Dim timesheetRow As TECMD.WSTimeSheet.TimesheetListDataSet.TimesheetsRow = timesheetListDS.Tables(0).Rows(0)
          Dim timesheetPeriodGUID As Guid = timesheetRow.WPRD_UID
          Dim timesheetDS As TECMD.WSTimeSheet.TimesheetDataSet = projUtility.wsTimeSheet.ReadTimesheetByPeriod(resGUID, timesheetPeriodGUID, TECMD.WSTimeSheet.Navigation.Current)
          Dim timesheetGUID As Guid = Nothing
          If timesheetDS.Headers.Count = 0 Then
            Dim timesheetSettingsDS As TECMD.WSAdmin.TimeSheetSettingsDataSet = projUtility.wsAdmin.ReadTimeSheetSettings()
            Dim timesheetSettingsRow As TECMD.WSAdmin.TimeSheetSettingsDataSet.TimeSheetSettingsRow = timesheetSettingsDS.TimeSheetSettings.Rows(0)
            timesheetDS = New TECMD.WSTimeSheet.TimesheetDataSet()
            Dim headersRow As TECMD.WSTimeSheet.TimesheetDataSet.HeadersRow = timesheetDS.Headers.NewHeadersRow()
            timesheetGUID = Guid.NewGuid()
            headersRow.RES_UID = resGUID
            headersRow.TS_UID = timesheetGUID
            headersRow.WPRD_UID = timesheetPeriodGUID
            headersRow.TS_CREATOR_RES_UID = resGUID
            headersRow.TS_NAME = "Timesheet Test"
            headersRow.TS_COMMENTS = "Comment"
            headersRow.TS_ENTRY_MODE_ENUM = timesheetSettingsRow.WADMIN_TS_DEF_ENTRY_MODE_ENUM 'Microsoft.Office.Project.Server.Library.TimesheetEnum.EntryMode.Daily 
            projUtility.wsTimeSheet.CreateTimesheet(timesheetDS, TECMD.WSTimeSheet.PreloadType.Default)
            timesheetDS = projUtility.wsTimeSheet.ReadTimesheet(timesheetGUID)
            timesheetGUID = timesheetDS.Headers(0).TS_UID
          End If
          Dim lineItem As TECMD.WSTimeSheet.TimesheetDataSet.LinesRow = timesheetDS.Lines.Select("ASSN_UID = '" & _selAssignmentUID.ToString() & "'")(0)
          Dim actualsRows As TECMD.WSTimeSheet.TimesheetDataSet.ActualsRow() = timesheetDS.Actuals.Select("TS_ACT_START_DATE = '" & _date & "' AND TS_LINE_UID = '" & lineItem.TS_LINE_UID.ToString() & "'")
          Dim selActualsRow As TECMD.WSTimeSheet.TimesheetDataSet.ActualsRow = actualsRows(0)
              Dim row As TECMD.WSTimeSheet.TimesheetDataSet.StatusingChangeLogRow = timesheetDS.StatusingChangeLog.NewStatusingChangeLogRow()
          row.PROJ_UID = lineItem.PROJ_UID
          row.ENTITY_TYPE = Microsoft.Office.Project.Server.Library.ProjectDataType.Assignment
          row.ENTITY_UID = lineItem.ASSN_UID
          row.PID = Microsoft.Office.Project.Server.Library.AssnConstID.s_apid_sched_work 
          selActualsRow.TS_ACT_PLAN_VALUE = CDec(((_actWork + _nonBillableWork) * 60000))
          selActualsRow.TS_ACT_COMMENT = reportingComment
          selActualsRow.TS_ACT_VALUE = CDec(_actWork * 60000)
          selActualsRow.TS_ACT_NON_BILLABLE_VALUE = CDec(_nonBillableWork * 60000)
    Dim jobUID As Guid = Guid.NewGuid()
    Dim status As String = ""
            projUtility.wsTimeSheet.QueueUpdateTimesheet(jobUID, timesheetGUID, timesheetDS.GetChanges())
    End If


    Thanks in advance!



    Monday, May 2, 2011 2:19 PM

All replies

  • I'm facing this very same problem. I think you're on the right track, but contrary to what's stated on the SDK, you're not using any Statusing methods, and i'd say that's exactly what's missing from your code. You're creating a StatusChange log record, but not doing any real statusing change. The real problem here is how to use the Statusing service to do want we want to do, as it's much less intuitive than the Timesheet service.

    Saturday, May 21, 2011 3:39 PM