Approval of timesheet update using CSOM RRS feed

  • General discussion

  • Hi,

    Is there any way to approve a timesheet update using CSOM for Project Online? I tried to forcefully set the timesheet status as Approved using the following piece of code(using the context of the same user whose timesheet I wish to approve; since I can't load properties of timesheet using other user's context). The code didn't give me any error but also didn't change the status of timesheet. 

    public static void TimesheetApprovalCheck(Guid timesheetId, Guid periodId, DateTime startDate)
        using (projectContext)
                    projectContext.Load(projectContext.TimeSheetPeriods, c => c.Where(p => p.Start == startDate && p.Id == periodId).
                       Include(p => p.TimeSheet));      
                    var period = projectContext.TimeSheetPeriods.FirstOrDefault();
                    period.TimeSheet.Status = TimeSheetStatus.Approved;

    I am stuck. Please help me if there is something wrong with the above code or if there is any other way I can accomplish this.

    Thursday, May 30, 2019 7:33 AM