none
Tasks created using PSI has incorrect duration RRS feed

  • Question

  • Hi,

    I'm using the following code to create projects tasks within workflow using PSI. The start date and end date that I'm using to create tasks are "Start Date: 8/7/2012" and "End Date: 8/15/2012" so the duration will be 7 days but when I go to the project schedule, the end date will be "8/14/2012" which makes the duration 6 days.

    What is wrong with that:

    	Dim projectClient As SvcProject.ProjectClient = WorkflowHelper.PSIProxy.GetProjectClient(wfContext.Site.Url)
            Dim projectDataSet As SvcProject.ProjectDataSet = projectClient.ReadProject(projectSequence1.WorkflowContext.ProjectUid, SvcProject.DataStoreEnum.WorkingStore)
            Dim newProjectDataSet As New SvcProject.ProjectDataSet
    
            If projectDataSet.Task.Rows.Count = 1 AndAlso DelivrablesXML(0) IsNot Nothing AndAlso String.IsNullOrEmpty(DelivrablesXML(0).ToString()) = False Then
    
    
                Dim sessionUID As Guid = Guid.NewGuid()
                
                projectClient.CheckOutProject(projectSequence1.WorkflowContext.ProjectUid, sessionUID, "Settings Project Delivrables in session " + sessionUID.ToString())
    
                Dim jsSerializer As New System.Web.Script.Serialization.JavaScriptSerializer
    
                Dim arr As Object() = CType(jsSerializer.DeserializeObject(DelivrablesXML(0)), Object())
    
                If arr IsNot Nothing Then
    
                    For Each a As Dictionary(Of String, Object) In arr
    
                        Dim newTask As SvcProject.ProjectDataSet.TaskRow = newProjectDataSet.Task.NewTaskRow
    
                        Dim startDate As Date = CDate(a("StartDate"))
                        Dim endDate As Date = CDate(a("EndDate"))
    
                        newTask.TASK_NAME = a("Name").ToString()
                        newTask.TASK_START_DATE = New DateTime(Year(startDate), Month(startDate), Day(startDate), 8, 0, 0)
                        newTask.TASK_FINISH_DATE = New DateTime(Year(endDate), Month(endDate), Day(endDate), 8, 0, 0)
                        newTask.TASK_DUR = 33600
                        'newTask.TASK_IS_MILESTONE = True
                        newTask.TASK_DUR_FMT = Microsoft.Office.Project.Server.Library.Task.DurationFormat.Day
                        newTask.TASK_CONSTRAINT_TYPE = CShort(Microsoft.Office.Project.Server.Library.Task.ConstraintType.AsSoonAsPossible)
                        newTask.TASK_DUR_IS_EST = True
                        newTask.TASK_LEVELING_DELAY_FMT = CShort(Microsoft.Office.Project.Server.Library.Task.DurationFormat.Day)
                        newTask.TASK_DUR_VAR = 0
                        newTask.TASK_ACT_START = CDate(a("StartDate"))
                        newTask.PROJ_UID = projectSequence1.WorkflowContext.ProjectUid
                        newTask.TASK_UID = Guid.NewGuid()
    
                        newProjectDataSet.Task.AddTaskRow(newTask)
    
                    Next
    
                    Dim updateJobUID As Guid = Guid.NewGuid()
                    
                    projectClient.QueueAddToProject(updateJobUID, sessionUID, newProjectDataSet, False)
                    WaitForQueue(updateJobUID)
                    
                End If
    
                Dim checkinJobUID As Guid = Guid.NewGuid()
                            
                projectClient.QueueCheckInProject(checkinJobUID, projectSequence1.WorkflowContext.ProjectUid, True, sessionUID, "Settings Project Delivrables in session " + sessionUID.ToString())
                WaitForQueue(checkinJobUID)
                
    
            End If

    And here is the XML related to one of those tasks:

    <Task>
        <PROJ_UID>e4c3f892-8126-43be-a094-06c9e2978f86</PROJ_UID>
        <TASK_UID>79546419-edc6-4d62-9df7-cbb98e27ca7d</TASK_UID>
        <TASK_PARENT_UID>873a3348-44cc-4a5f-a21f-19a6e11de4f7</TASK_PARENT_UID>
        <TASK_NAME>Task 1</TASK_NAME>
        <TASK_ID>1</TASK_ID>
        <TASK_IS_MILESTONE>false</TASK_IS_MILESTONE>
        <TASK_IS_SUMMARY>false</TASK_IS_SUMMARY>
        <TASK_IS_MARKED>false</TASK_IS_MARKED>
        <TASK_IGNORES_RES_CAL>false</TASK_IGNORES_RES_CAL>
        <TASK_IS_EFFORT_DRIVEN>false</TASK_IS_EFFORT_DRIVEN>
        <TASK_IS_CRITICAL>true</TASK_IS_CRITICAL>
        <TASK_IS_EXTERNAL>false</TASK_IS_EXTERNAL>
        <TASK_IS_FROM_FINISH_SUBPROJ>false</TASK_IS_FROM_FINISH_SUBPROJ>
        <TASK_IS_OVERALLOCATED>false</TASK_IS_OVERALLOCATED>
        <TASK_IS_RECURRING>false</TASK_IS_RECURRING>
        <TASK_IS_RECURRING_SUMMARY>false</TASK_IS_RECURRING_SUMMARY>
        <TASK_IS_SUBPROJ>false</TASK_IS_SUBPROJ>
        <TASK_IS_READONLY_SUBPROJ>false</TASK_IS_READONLY_SUBPROJ>
        <TASK_LOCKDOWN_BY_MANAGER>false</TASK_LOCKDOWN_BY_MANAGER>
        <TASK_LEVELING_DELAY>0</TASK_LEVELING_DELAY>
        <TASK_LEVELING_DELAY_FMT>8</TASK_LEVELING_DELAY_FMT>
        <TASK_LEVELING_CAN_SPLIT>true</TASK_LEVELING_CAN_SPLIT>
        <TASK_LEVELING_ADJUSTS_ASSN>false</TASK_LEVELING_ADJUSTS_ASSN>
        <TASK_DUR_IS_EST>false</TASK_DUR_IS_EST>
        <TASK_DUR>28800</TASK_DUR>
        <TASK_DUR_FMT>7</TASK_DUR_FMT>
        <TASK_DUR_VAR>0</TASK_DUR_VAR>
        <TASK_EAC>0</TASK_EAC>
        <TASK_VAC>0</TASK_VAC>
        <TASK_ACT_DUR>0</TASK_ACT_DUR>
        <TASK_REM_DUR>28800</TASK_REM_DUR>
        <TASK_CONSTRAINT_TYPE>6</TASK_CONSTRAINT_TYPE>
        <TASK_CONSTRAINT_DATE>2012-08-15T08:00:00+03:00</TASK_CONSTRAINT_DATE>
        <TASK_ACT_START>2012-08-07T00:00:00+03:00</TASK_ACT_START>
        <TASK_PRIORITY>500</TASK_PRIORITY>
        <TASK_PCT_COMP>0</TASK_PCT_COMP>
        <TASK_PCT_WORK_COMP>0</TASK_PCT_WORK_COMP>
        <TASK_TYPE>0</TASK_TYPE>
        <TASK_FIXED_COST_ACCRUAL>3</TASK_FIXED_COST_ACCRUAL>
        <TASK_WORK>0</TASK_WORK>
        <TASK_OVT_WORK>0</TASK_OVT_WORK>
        <TASK_REG_WORK>0</TASK_REG_WORK>
        <TASK_ACT_WORK>0</TASK_ACT_WORK>
        <TASK_ACT_OVT_WORK>0</TASK_ACT_OVT_WORK>
        <TASK_REM_WORK>0</TASK_REM_WORK>
        <TASK_REM_OVT_WORK>0</TASK_REM_OVT_WORK>
        <TASK_COST>0</TASK_COST>
        <TASK_OVT_COST>0</TASK_OVT_COST>
        <TASK_FIXED_COST>0</TASK_FIXED_COST>
        <TASK_ACT_COST>0</TASK_ACT_COST>
        <TASK_ACT_OVT_COST>0</TASK_ACT_OVT_COST>
        <TASK_REM_COST>0</TASK_REM_COST>
        <TASK_REM_OVT_COST>0</TASK_REM_OVT_COST>
        <TASK_OUTLINE_LEVEL>1</TASK_OUTLINE_LEVEL>
        <TASK_OUTLINE_NUM>1</TASK_OUTLINE_NUM>
        <TASK_START_DATE>2012-08-07T00:00:00+03:00</TASK_START_DATE>
        <TASK_START_VAR>0</TASK_START_VAR>
        <TASK_FINISH_DATE>2012-08-14T17:00:00+03:00</TASK_FINISH_DATE>
        <TASK_FINISH_VAR>0</TASK_FINISH_VAR>
        <TASK_RESUME_DATE>2012-08-07T08:00:00+03:00</TASK_RESUME_DATE>
        <TASK_STOP_DATE>2012-08-07T00:00:00+03:00</TASK_STOP_DATE>
        <TASK_EARLY_START>2012-08-07T00:00:00+03:00</TASK_EARLY_START>
        <TASK_EARLY_FINISH>2012-08-14T17:00:00+03:00</TASK_EARLY_FINISH>
        <TASK_LATE_START>2012-08-07T00:00:00+03:00</TASK_LATE_START>
        <TASK_LATE_FINISH>2012-08-14T17:00:00+03:00</TASK_LATE_FINISH>
        <TASK_BCWS>0</TASK_BCWS>
        <TASK_BCWP>0</TASK_BCWP>
        <TASK_ACWP>0</TASK_ACWP>
        <TASK_FREE_SLACK>0</TASK_FREE_SLACK>
        <TASK_TOTAL_SLACK>0</TASK_TOTAL_SLACK>
        <TASK_HAS_LINKED_FIELDS>false</TASK_HAS_LINKED_FIELDS>
        <CREATED_DATE>2012-08-06T15:29:47.97+03:00</CREATED_DATE>
        <MOD_DATE>2012-08-06T15:30:17.74+03:00</MOD_DATE>
        <TASK_BUDGET_COST>0</TASK_BUDGET_COST>
        <TASK_IS_NULL>false</TASK_IS_NULL>
        <TASK_BUDGET_WORK>0</TASK_BUDGET_WORK>
        <TASK_COST_VAR>0</TASK_COST_VAR>
        <TASK_CPI>0</TASK_CPI>
        <TASK_CV>0</TASK_CV>
        <TASK_START_SLACK>0</TASK_START_SLACK>
        <TASK_FINISH_SLACK>0</TASK_FINISH_SLACK>
        <TASK_IS_ROLLED_UP>false</TASK_IS_ROLLED_UP>
        <TASK_SV>0</TASK_SV>
        <TASK_TCPI>0</TASK_TCPI>
        <TASK_WORK_VAR>0</TASK_WORK_VAR>
        <TASK_COMPLETE_THROUGH>2012-08-07T08:00:00+03:00</TASK_COMPLETE_THROUGH>
        <TASK_IS_MANUAL>false</TASK_IS_MANUAL>
        <TASK_IS_ACTIVE>true</TASK_IS_ACTIVE>
        <TASK_IS_DISPSUMMARY>false</TASK_IS_DISPSUMMARY>
        <TASK_SCHED_START>2012-08-07T00:00:00+03:00</TASK_SCHED_START>
        <TASK_SCHED_FINISH>2012-08-14T17:00:00+03:00</TASK_SCHED_FINISH>
        <TASK_SCHED_DUR>28800</TASK_SCHED_DUR>
        <TASK_SCHED_DUR_FMT>7</TASK_SCHED_DUR_FMT>
      </Task>

    Monday, August 6, 2012 8:07 PM

All replies

  • Hi,

    As for Project Pro what happens if you only specify a duration? If you start specifying dates, then constraint dates happen and you now have to manually maintain dates for all tasks, which is what Project is meant to do for you. Ideally the start date is calculated by Project based on preceding tasks and links to them and the finish date is calculated by Project based on the duration and calendar for the Project or task (if one is specified).


    Rod Gill

    The one and only Project VBA Book

    Rod Gill Project Management

    Tuesday, August 14, 2012 1:48 AM
    Moderator
  • Thanks for your reply,

    On PWA, When I create a manual schedule task and specifying the start and end date of that task without duration, the system will calcualate the duration correctly, but when I do that from the code the duration will not be calcualted correctly.

    I serialized each task and compared the XML related to each one of them and I could find differences like:

    - TASK_DUR_FMT

    - TASK_CONSTRAINT_TYPE

    and another things and I tried to set that by code but the system igoners them.

    Any suggested idea?

    Sunday, August 26, 2012 10:18 AM
  • Duration is tracked in units of minutes...is it possible you need to multiply
    whatever you're entering by a multiple of 60?
     
     

    Andrew Lavinsky [MVP] Blog: http://azlav.umtblog.com Twitter: @alavinsky
    Sunday, August 26, 2012 5:34 PM
    Moderator