Sunday 20 January 2019

CSOM: Working with Office365 Project Online Tasks - Part II

This article explains steps for adding, updating or deleting a task to/from Office 365 Project Online plan schedules.

This article series focuses on working with  office 365 project online plan schedule tasks using Client Side Object model approach. In the previous post, we have seen multiple ways of retrieving tasks from the project plans.



Adding a Task: 


A task can be added to the Office 365 project plan schedule by the following steps.
  • Required project needs to be checked-out before any operation. 
  • Task collection is retrieved from the draft project. 
  • Task creation object is created with necessary OOB field values, and will be added to the task collection. 
  • Then the draft project will be updated and published. 


The following code snippet shows the above explained steps.


Updating a Task: 


A task can be update on the Office 365 project plan schedule by the following steps.
  • Required project needs to be checked-out before any operation. 
  • Task collection is retrieved from the draft project. 
  • Task is retrieved from the task collection. 
  • Necessary OOB/custom fields can be set with new values. 
  • Then the draft project will be updated and published. 
  • Execute query using Project context . 

The following code snippet shows the update operation.

Deleting a Task: 


A task can be deleted from the Office 365 project plan schedule by the following steps.
  • Check-out the project, and retrieve the tasks collection. 
  • Retrieve the task from the task collection. 
  • Delete the task object. 
  • Then the draft project will be updated and published. 
  • Execute query using Project context . 

The following code snippet shows the delete operation.