none
Unable to Update Tasks using PSI RRS feed

  • Question

  • Hi,

    I have customized Ms Project Server to update a custom field in the tasks of Project Schedule after checkin of the Project.

    The code loops through all tasks and performs QueueUpdate operation to update all changes to Tasks. However, the updates made to the last task of the Project are updated in the system, no changes are saved for rest of the tasks.

    Could you please help provide some help in resolving this issue? Any help in this regard would be appreciated.

    Monday, November 3, 2014 3:54 PM

All replies

  • Hi,

    As we haven't seen the code I would suggest to check:

    - if the dataset is updated after parsing each task in your schedule

    - taskUid updated accordingly

    Hope this helps

    Paul

    Monday, November 3, 2014 8:54 PM
  •    
    Hi,

    I am trying to update Task Custom Fields in project server 2010.But it is throwing error at QueueUpdate Method.

    At projectSvc.QueueUpdateProject(jobId, sessionId, myProject, false);

    it is giving error:

    "ProjectServerError(s) LastError=CustomFieldRowAlreadyExists Instructions: Pass this into PSClientError constructor to access all error information
       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at UpdateProjectStoreInformation.ProjectWebSvc.Project.QueueUpdateProject(Guid jobUid, Guid sessionUid, ProjectDataSet dataset, Boolean validateOnly)
       at UpdateProjectStoreInformation.ProjectListEventReceiver.ProjectListEventReceiver.ItemAdded(SPItemEventProperties properties)"

    Code is written below:

    if (taskEfforts != null && taskEfforts.Count > 0)
                                    {

                                       
                                        for (int i = 0; i < myProject.Task.Count; i++)
                                        {
                                            foreach (string key in taskEfforts.Keys)
                                            {
                                                if (myProject.Task[i].TASK_NAME.ToString().ToLower().Equals(key.ToString().ToLower()))
                                                {
                                                    foreach (ProjectDataSet.TaskCustomFieldsRow cfRow in myProject.TaskCustomFields)
                                                    {
                                                        if (cfRow.MD_PROP_UID == effortGuid)
                                                        {                                                      
                                                            Logger.WriteLog("********Updating Efforts**********");
                                                            cfRow.NUM_VALUE = Convert.ToDecimal(taskEfforts[key]);                                           
                                                                                                           
                                                            Logger.WriteLog("task name:" + myProject.Task[i].TASK_NAME + " Effort:" + taskEfforts[key]);
                                                            break;
                                                        }
                                                    }
                                                    //break
                                                   
                                                }
                                            }
                                        }
                                      
                                        bool force = true;
                                        sessionId = Guid.NewGuid();
                                        string sessionDescription = "updated custom fields";                                  
                                        projectSvc.CheckOutProject(projectGuid, sessionId,
                                                                   "custom field update checkout");

                                      jobId = Guid.NewGuid();
                                      projectSvc.QueueUpdateProject(jobId, sessionId, myProject, false);
                                      WaitForJob(jobId);

          jobId = Guid.NewGuid();
                              projectSvc.QueuePublish(jobId, projectGuid, true, siteName);

                          
                             //create a new job id
                             jobId = Guid.NewGuid();

                            //checkin the updated project                      
                            projectSvc.QueueCheckInProject(jobId, projectGuid,
                                force, sessionId, sessionDescription);
                          
                            //wait for finishing
                            WaitForJob(jobId);

       }

    Thanks

    Wednesday, November 5, 2014 8:47 AM
  • Hi,

    I quickly scanned your code and there are couple of things I notice:

    1. you are using the task name to identify which tasks to update and if you have multiple tasks with the same name then multiple tasks will be updated

    2. try to change this line

     if (cfRow.MD_PROP_UID == effortGuid)

    to  

    if (cfRow.MD_PROP_UID == effortGuid &&  myProject.Task[i].TASK_UID == cfRow.Task_UID)

    Hope this helps

    Paul

    Wednesday, November 5, 2014 10:44 AM
  • Hi Paul,

    I tried that but it is giving me same error .

    Thanks

    Thursday, November 6, 2014 9:09 AM
  • Hi Abhijit PS,

    Have a look at the TaskCustomFields DataTable in the myProject dataset (DataSet Visualizer) before executing the QueueUpdateProject method.

    Do you see any records with a duplicate [TASK_UID] and [MD_PROP_UID] ?

    Analyzing the data in the TaskCustomFields datatable should help you find the cause of the error and fix the code.

    Hope this helps

    Thursday, November 6, 2014 10:05 AM
  • Hi,

    I wonder if this is not caused by having two tasks with the same name in your project plan.

    Have you tested you code with a simple project schedule (e.g. Task 1, Task 2 etc.)?

    Also, when testing make sure you are using the latest version of your code/assembly

    Paul

    Thursday, November 6, 2014 10:35 AM