none
Programmatically add an existing task assignment to resource timesheet RRS feed

  • Question

  • hello forum members,

    I am working on code that creates tasks for a project, assigns resources to task and then adds that tasks to resources timesheets so that they could log time against it. 

    Can you anyone recommend any code samples or link references on how to add an existing task assignment to a resource timesheet?

    tatiana


    tatiana

    Monday, September 8, 2014 8:30 PM

Answers

  • Hi Tatiana,

    Check following code sample (PSI):

    WebSvcTimeSheet.TimesheetDataSet dsTimeSheet = SvcTimeSheet.ReadTimeSheet(<TimesheetUID>);
    
    WebSvcTimeSheet.TimesheetDataSet.LinesRow newLine = dsTimeSheet.Lines.NewLinesRow();
    
    newLine.TS_LINE_UID = Guid.NewGuid();
    newLine.TS_UID = <TimesheetUID>;
    newLine.TS_LINE_CLASS_UID = TimesheetConst.const_StandardLineClassGuid;
    newLine.TS_LINE_VALIDATION_TYPE = (byte)TimesheetEnum.ValidationType.Unverified;
    newLine.TS_LINE_STATUS = (byte)TimesheetEnum.LineStatus.Approved;
    newLine.PROJ_UID = <ProjectUID>;
    newLine.TASK_UID = <TaskUID>;
    newLine.TS_LINE_CACHED_ASSIGN_NAME = <Task Name>;
    newLine.TS_LINE_CACHED_PROJ_NAME = <PROJ NAME>;
    newLine.SetTS_LINE_COMMENTNull();
    
    dsTimeSheet.Lines.AddLinesRow(newLine);
    
    SvcTimeSheet.PrepareTimesheetLine(<TimesheetUID>, ref dsTimeSheet, new[] { newLine.TS_LINE_UID });
    
    Guid jobUid = Guid.NewGuid();
    SvcTimeSheet.QueueUpdateTimesheet(jobUid, <TimesheetUID>, dsTimeSheet);

    Make sure you have the Microsoft.Office.Project.Server.Library referenced in your project.

    Hope this helps

    • Marked as answer by tatiana obrien Tuesday, October 21, 2014 8:55 PM
    Wednesday, September 17, 2014 11:33 AM