Saturday 22 December 2018

Working with Office365 Project Online Tasks using JSOM - Part I

This article series focuses on working with office 365 project online plan schedule tasks using JSOM approach. The operations like create, retrieve, update or delete project task operations are explained.

Here in this article, let us look at creating or retrieving project schedule tasks using JSOM approach. 

Office 365 Microsoft Project Online helps creating project plans, managing schedules and collaborating with other resources virtually. Project plans, task schedules and other objects on the Microsoft Project online can be accessed or created or updated programmatically. Microsoft documentation site  provides REST endpoints for working with project online objects. 


Load prerequisite files and context: 


To get the project server context working, first let us see the prerequisite files to be loaded for getting the project online contexts. The following piece of code shows how the required Project Server/SharePoint files and contexts (PS/SP) are loaded. 


Create Task on Project Schedule:


To create a task on the project, the following operations are required. 

  • Check-out a project – This operation involves get project by GUID and check-out. 
  • Add a task with project name and other OOB fields. - This operation involves steps like get project by GUID, then get the project draft, get the task collection from the project draft, set task creation object with OOB field values, add task creation object to the task collection retrieved, and update project draft. 
  • Publish & check-in the project. - This operation involves get project by GUID, get the project draft, publish/check-in the project. 

Note: Setting a custom field on task creation is not feasible, but a custom field value can be set on the update operation. It will be explained in the later section. 
For example, assume a project is already created and available for use. The following piece of code helps understanding task creation steps explained. 



Retrieve Task from Project Schedule: 


The following piece of code shows the getting tasks as collection and getting task by GUID. 


In the next article let us look at updating or deleting project online tasks using JSOM.