Add TimeSheet Line Classification using CSOM Project Online

Add TimeSheet  Line Classification using CSOM Project Online

Add TimeSheet Line Classification using CSOM Project Online. In this post, I will describe you to Add TimeSheet  Line Classification using CSOM Project Online.Each line in timesheet is used to capture actual work for the selected reporting period. Add TimeSheet  Line Classification using CSOM Project Online then the same code will help you also.Below is complete code for Add TimeSheet  Line Classification using CSOM Project Online.

If you don’t know to add references in your solutions then follow the post below

Add  references in Solution


public static void AddLineClassificationTimeSheet()
                using (ProjectContext ProjectCont = new ProjectContext(PWA))//PWA Url
                    SecureString passWord2 = new SecureString();
                    foreach (char c in Passwords.ToCharArray()) passWord2.AppendChar(c);
                    ProjectCont.Credentials = new SharePointOnlineCredentials(UserName, passWord2);
                    c => c.IncludeWithDefaultProperties());
                    ProjectCont.Load(ProjectCont.TimeSheetPeriods, c => c.Where(p => p.Start <= DateTime.Now && p.End >= DateTime.Now).
                        IncludeWithDefaultProperties(p => p.TimeSheet,
                                                     p => p.TimeSheet.Lines.Where(l => l.LineClass == TimeSheetLineClass.StandardLine).
                        IncludeWithDefaultProperties(l => l.Assignment,
                                                           l => l.Assignment.Task,
                                                           l => l.Work)));

                    var myPeriod = ProjectCont.TimeSheetPeriods.FirstOrDefault();

                    if (myPeriod == null)
                        throw new Exception("Create the periods");
                    TimeSheetLineCreationInformation ln = new TimeSheetLineCreationInformation();
                    ln.TaskName = "TaskName";
                    if (myPeriod.TimeSheet.Status == TimeSheetStatus.Approved ||
                        myPeriod.TimeSheet.Status == TimeSheetStatus.Submitted ||
                        myPeriod.TimeSheet.Status == TimeSheetStatus.Rejected)
            catch (Exception ex)


Some useful links-

Add actual Hours in TimeSheet using CSOM Project Online

Read TimeSheet Data using CSOM Project Online


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!