none
Add task to project using CSOM - Project Server 2013 RRS feed

  • Question

  • Hi. I'm trying to add a task to a project using CSOM, but I always get an exception in return.
    Here's a piece of my code:

    using (projContext = new ProjectContext(pwaPath))
    {
        SecureString passWord = new SecureString();
        foreach (char c in connectPwd.ToCharArray()) passWord.AppendChar(c);
        projContext.Credentials = new SharePointOnlineCredentials(connectUserName, passWord);
    }
    
    var projCollection = projContext.LoadQuery(
        projContext.Projects
            .Where(p => p.Name == projName));
    
    projContext.ExecuteQuery();
    
    if (projCollection.Count() > 0)
    {
        PublishedProject proj2Edit = projCollection.First();
    
        DraftProject projCheckedOut = proj2Edit.CheckOut();
    
        // Create a task.
        TaskCreationInformation newTask = new TaskCreationInformation();
        newTask.Name = "Test";
        newTask.IsManual = false;
        newTask.Duration = "3d";
        newTask.Start = DateTime.Today;
    
        // Add the task to the checked out project.
        projCheckedOut.Tasks.Add(newTask);
        projCheckedOut.Publish(true);
    
        // Update the published projects collection.
        QueueJob qJob = projContext.Projects.Update();
        JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds);
    
        if (jobState == JobState.Success)
        {
            Console.WriteLine("\nSuccess!");
        }
        else
        {
            Console.WriteLine("\nThere is a problem in the queue. Timeout is {0} seconds.",
                timeoutSeconds);
        }
    }
    else
    {
        Console.WriteLine("\nNo project with the name '{0}'", projName);
    }

    I always see Success! as a result, but in Project Online I see this error:

    • GeneralQueueException:
      • GeneralQueueException (9131). Detalles: id='9131' name='GeneralQueueException' uid='eb7f7781-2410-e311-98be-00155d00480b' messageID='2' exception='System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Office.Project.Server.BusinessLayer.ProjectEngineUpdate.HandleSSPUpdates() at Microsoft.Office.Project.Server.BusinessLayer.ProjectEngineUpdate.HandleUpdate() at Microsoft.Office.Project.Server.BusinessLayer.ProjectQueueDispatch.HandleProject2(MessageContext mContext, ProjectMain project, ServerEventManager sem, ProjectDataSet dataset, Guid projectUid, Guid sessionUid) at Microsoft.Office.Project.Server.BusinessLayer.ProjectQueueDispatch.InternalDispatchMessage(IPlatformContext context, Message msg, Group messageGroup, JobTicket jobTicket, MessageContext mContext)'.
    • Queue:
      • GeneralQueueJobFailed (26000) - ProjectUpdate.ProjectUpdate2Message. Detalles: id='26000' name='GeneralQueueJobFailed' uid='ec7f7781-2410-e311-98be-00155d00480b' JobUID='854bbd7f-2410-e311-99a4-00155d9cbe08' ComputerName='59c3d949-216d-472d-a8b1-2b2f33b57f66' GroupType='ProjectUpdate' MessageType='ProjectUpdate2Message' MessageId='2' Stage='' CorrelationUID='4a8e3d9c-baea-b083-4282-05d97120a1cf'. Para obtener más información, compruebe que el ULS inicie sesión en el equipo 59c3d949-216d-472d-a8b1-2b2f33b57f66 para las entradas con JobUID 854bbd7f-2410-e311-99a4-00155d9cbe08

    Thursday, August 29, 2013 12:44 PM

All replies

  • Any success with the issue?

    I also have the same error when removing task.


    AlexJ

    Sunday, January 12, 2014 7:47 AM
  • Been figthing this issue a long time now.

    There are many suggestions in which order to update/publish/checkin. See this page for an alternative example: http://msdn.microsoft.com/en-us/library/microsoft.projectserver.client.draftproject.update_di_pj14mref(v=office.15).ASPX

    I finally got the code to work, however i can only get the code to work on a non-updated Project Server instanse.

    The PS-version that works: 15.0.4481.1005 (Before SP1, i think)

    The PS-version that does not work: 15.0.4569.1506 (SP1/CU Aug)

    -----------------------------------------------------------------------------------------

    Update code that works:


    DraftProject draft2Edit = proj2Edit.CheckOut();

                    projContext.Load(draft2Edit);
                    projContext.Load(draft2Edit.Tasks);
                    projContext.ExecuteQuery();

                    TaskCreationInformation newTask = new TaskCreationInformation();
                    newTask.Name = taskName;
                    newTask.IsManual = false;
                    newTask.Start = startdate;
                    newTask.Id = nameHelpGuid;
                    newTask.Finish = enddate;

                    DraftTask draftTask = draft2Edit.Tasks.Add(newTask);

                    draft2Edit.Publish(true);

                    // Update the published projects collection.
                    qJob = projContext.Projects.Update();
                    jobState = projContext.WaitForQueue(qJob, timeoutSeconds);

                    if (jobState == JobState.Success)
                    {
                        Console.WriteLine("\nSuccess!");
                    }

    ------------------------------------------------------------------------------------------

    Version details (PS where code works):

                        

    Microsoft® Project Server 2013   Installed 

     Microsoft Project Server 2013 
     15.0.4481.1005 Installed 

     Update for Microsoft Project Server 2013 (KB2768001) 64-Bit Edition 
     15.0.4481.1005 Installed 

     Microsoft Project Server English Language Pack 
     15.0.4420.1017 Installed 

     Hotfix for Microsoft Project Server 2013 (KB2817615) 64-Bit Edition 
     15.0.4535.1000 Installed 

     Hotfix for Microsoft Project Server 2013 (KB2817415) 64-Bit Edition 
     15.0.4517.1005 Superseded 

     Microsoft Project Server Web Front End Server 
     15.0.4481.1005 Installed 

     Hotfix for Microsoft Project Server 2013 (KB2817615) 64-Bit Edition 
     15.0.4535.1000 Installed 

     Hotfix for Microsoft Project Server 2013 (KB2817415) 64-Bit Edition 
     15.0.4517.1005 Superseded 

     Hotfix for Microsoft Project Server 2013 (KB2760261) 64-Bit Edition 
     15.0.4505.1002 Superseded 

     Update for Microsoft Project Server 2013 (KB2768001) 64-Bit Edition 
     15.0.4481.1005 
    -----------------------------------------------------------------------------------------

    Version details (PS where code does not work):

                

     Microsoft® Project Server 2013   Installed 

     Microsoft Project Server 2013 
     15.0.4569.1506 Installed 

     Service Pack 1 for Microsoft Project Server 2013 (KB2817434) 64-Bit Edition 
     15.0.4569.1506 Installed 

     Microsoft Project Server English Language Pack 
     15.0.4569.1506 Installed 

     Service Pack 1 for Microsoft Project Server 2013 (KB2817434) 64-Bit Edition 
     15.0.4569.1506 Installed 

     Microsoft Project Server Web Front End Server 
     15.0.4569.1506 Installed 

     Service Pack 1 for Microsoft Project Server 2013 (KB2817434) 64-Bit Edition 
     15.0.4569.1506 



    http://technicaltrix.blogspot.dk/


    Saturday, September 13, 2014 3:27 PM
  • Is there a solution for this problem?

    I'm also getting the same issue when updating tasks on Project Server 2013 SP1 (15.0.4569.1506).

    Maybe it was fixed in a cumulative update?

    Wednesday, October 7, 2015 8:30 AM
  • Ditto.  It would be great to see a solution to this problem as it appears to be consistently happening to a number of people!
    Tuesday, December 8, 2015 3:16 PM
  • I had a similar issue when I was developing the code earlier this year, I used PS2013 with earlier patches and once I Patched the FARM with Feb 2015 release it worked like a charm. This is what I have experienced earlier this year. 


    Regards, Syed Faizan ur Rehman, CBPM®,PRINCE2®, MCTS


    Wednesday, December 9, 2015 5:26 AM