[EPM - PSI] Insert a sub task link to an existing task - TaskCannotAddWhereSpecified
-
28 marca 2012 14:25
Hello,
I m trying to insert, by code (calling Project.svc service), a new sub task (level 2)
The task should be postionned at a certain row, not at the end of the project document.
Here is my code:
backendProject.ProjectDataSet prjDataSetPlanned = projectClient.ReadProject(projectId, backendProject.DataStoreEnum.PublishedStore); backendProject.ProjectDataSet.TaskRow taskPredRow = prjDataSetPlanned.Task[26]; backendProject.ProjectDataSet.TaskRow taskSuccRow = prjDataSetPlanned.Task[27]; backendProject.ProjectDataSet newDataSet = new backendProject.ProjectDataSet(); Guid taskPred = taskPredRow.TASK_UID; Guid taskSucc = taskSuccRow.TASK_UID; Guid newTaskId = Guid.NewGuid(); backendProject.ProjectDataSet.TaskRow newTask = newDataSet.Task.NewTaskRow(); newTask.PROJ_UID = projectId; newTask.TASK_UID = newTaskId; newTask.TASK_OUTLINE_LEVEL = 2; newTask.AddPosition = (int)PSLibrary.Task.AddPositionType.Middle; newTask.TASK_NAME = taskName; newTask.TASK_DUR = duration * 4800; newDataSet.Task.AddTaskRow(newTask); backendProject.ProjectDataSet.DependencyRow dependRow = newDataSet.Dependency.NewDependencyRow(); dependRow.PROJ_UID = projectId; dependRow.LINK_PRED_UID = taskPred; dependRow.LINK_SUCC_UID = taskSucc; dependRow.LINK_UID = Guid.NewGuid(); newDataSet.Dependency.AddDependencyRow(dependRow); projectClient.CheckOutProject(projectId, newSession, "Test checkout"); bool updateActualsvalidateOnly = false; projectClient.QueueAddToProject(JobId, newSession, newDataSet, updateActualsvalidateOnly); projectClient.QueuePublish(JobId, projectId, false, string.Empty); projectClient.QueueCheckInProject(JobId, projectId, false, newSession, "Update Actuals using PSI");The insert is working but always at the end of the document.
I have 7 Tasks (Milestones) which contains multiple of sub task. I would like to insert a new sub task between the row 26 and 27.
Unfortunately, i have got an error saying that i cannot insert my task there.
First: Is it possible to insert a task where we want into an existing document ?
Second: What's wrong with my code ?
Thank you for your support.
Math
- Zmodyfikowany przez Fix_105 29 marca 2012 13:18
Wszystkie odpowiedzi
-
29 marca 2012 07:37
Hi Math,
try something like this
task.AddAfterTaskUID = previoustask;
works fine for me.
Best regards
Björn
-
29 marca 2012 08:59
Already try,
By doing that, i have got the following error:
ProjectServerError(s) LastError=TaskCannotAddWhereSpecified Instructions: Pass this into PSClientError constructor to access all error information
Anyone had already the issue ?
Math
-
2 kwietnia 2012 15:06
Hi Fix_105,
if you set only previous task and not successor, your app work fine?
Or, if you set only
newTask.AddAfterTaskUID = taskPred;
without use DependencyRow, do you get what you want?
I hope this can helps you,
Best Regards
Paolo O.
-
2 kwietnia 2012 15:22
Hi Fix_105,
another thing; i check here: http://msdn.microsoft.com/en-us/library/websvcproject.projectdataset.taskrow.task_outline_level(v=office.12).aspx.
I don't know how your project plan is defined, but, in my opinion, you can set predecessor and successor without set TASK_OUTLINE_LEVEL.
In my opinion, you get an error because there are too many info regarding dependencies and position task.
I hope this can helps you,
Best Regards
Paolo O.
-
11 kwietnia 2012 13:32
I didn't find any solution.
For now, i just define the task as inactive (as it's for a demo) and i will activate the task once i will add.
Each time that i tried to insert the task with or without depency, the task was added at the end of the document. Could be normal. Anyway, i will do some test on a smaller project document.
Thanks for your support Paolo.
Math