none
Please help with setting Parent when creating new task via psi RRS feed

  • Question

  • I am able to add a task to a project, but I am unable to get the parent task value to "take".  After the task is added, it always has the root (top most task) as the parent.

    Can anyone tell me how to get the task parent to the value I need?  The following are code snippets showing the addition of the task.

    Thank you,

    //creating the taskrow and setting the TASK_PARENT_UID

     

    //clear readonly flag

    for (int j = 0; j < taskRow.Table.Columns.Count; j++)

                    { taskRow.Table.Columns[j].ReadOnly = false; }

     

     taskRow.PROJ_UID = ProjID;

     taskRow.TASK_UID = TaskID; //new guid

                   

     

    taskRow.TASK_PARENT_UID  = ParentID;

    taskRow.TASK_NAME = Name.DataValue;

     

    taskRow["TASK_START_DATE"] = !StartDate.DataValue.HasValue ? (object)System.DBNull.Value : (object)StartDate.DataValue.Value;

     

    taskRow["TASK_STOP_DATE"] = !StopDate.DataValue.HasValue ? (object)System.DBNull.Value : (object)StopDate.DataValue.Value;

    taskRow.TASK_DUR_FMT = (int) PSLib.Task.DurationFormat.Day; // DurFmt.DataValue;

    taskRow["TASK_DUR"] = !TaskDur.DataValue.HasValue ? (object)System.DBNull.Value : (object)TaskDur.DataValue.Value;

                   

     

    ……

    // creating a Dataset with only the new row created above

     

    ProjectWebSvc.ProjectDataSet UpdateTasksDS = new ProjectWebSvc.ProjectDataSet();

                UpdateTasksDS.Task.Merge((ProjectWebSvc.ProjectDataSet.TaskDataTable)this.ProjectDS.Task, true);

    UpdateTasksDS = (ProjectWebSvc.ProjectDataSet) UpdateTasksDS.GetChanges(System.Data.DataRowState.Added);

     

     

    // update using framework in ProjTool from SDK by sending the dataset created above

    Guid sessionGuid = Guid.NewGuid();

    Project.CheckOutProject(projectID, sessionGuid, "Checked out for Task update");

    Program.AddToProject(tasksToAddDS, projectServer, sessionGuid, false);

    Program.CheckInProject(projectServer, projectID, sessionGuid, true, "Checked in after Task update", false

    Value of parent is correct right before call to do update.

    Wednesday, May 11, 2011 10:36 PM

All replies

  • Unfortunately, you cannot insert a task in the middle of an existing project and change the TASK_UID order, or the TASK_PARENT_UID, by using public PSI methods. AddToProject always inserts a task at the end. QueueUpdateProject can change the TASK_OUTLINE_LEVEL of an existing task, but the TASK_UID and TASK_PARENT_UID fields (and a number of other fields) are read-only in the ProjectDataSet of an existing project.

    The reason is bacause there are limitations in the scheduling engine in Project Server 2010; it does not exactly duplicate the scheduling engine functionality in Proj Pro, so there are restrictions on what you can do with the public PSIs that would involve scheduling changes.

    You can use ProjTool to see the read-only fields in the Task table of a ProjectDataSet. The fields you would have to change are greyed out. PWA uses private methods (in the WinProj and PWA services) to insert tasks, change the task parent, and reschedule the project.

    --Jim


    Jim Corbin [MSFT]
    • Proposed as answer by Jim Corbin Saturday, May 14, 2011 11:56 PM
    Saturday, May 14, 2011 11:55 PM