Tuesday, 25 December 2018

Working with Office365 Project Online Tasks using JSOM - Part II

Views
In this article, let us look at updating or deleting tasks on Office 365 project online using JavaScript Object Model.

This article series focuses on working with office 365 project online plan schedule tasks using JSOM approach. The previous article explains creating or retrieving tasks on project online schedules using JSOM approach.


Update Task on Project Schedule 


To update a task on the project online, the following operations are performed.
  • Check-out a project – This operation involves get project by GUID and check-out. (If already checked out, this step is not required) 
  • Update task (OOB/custom fields can be updated) - This operation involves steps like get project by GUID, then get the project draft, get the task collection from the project draft, get task using task GUID, set necessary fields (OOB or custom) with values and updating project draft. 
  • Publish & check-in the project. - This operation involves get project by GUID, get the project draft, publish/check-in the project. (If other actions are involved, this step is not required)

Note: Check-out/Check-in operations are not shown in the piece of code below. If you are performing multiple actions/operations in the project, these actions need not be repeated multiple times. If you want to perform these operations, please refer to the previous article.

For example, assume a task is already created on the project. The following piece of code helps task updating task.


Delete Task on Project Schedule


To delete a task on the project online schedule, the following operations are performed.
  • Check-out a project – This operation involves get project by GUID and check-out. (If already checked out, this step is not required) 
  • Delete task - This operation involves steps like get project by GUID, then get the project draft, get the task collection from the project draft, get task using task GUID, delete the task using deleteObject method and updating project draft. 
  • Publish & check-in the project. - This operation involves get project by GUID, get the project draft, publish/check-in the project. (If other actions are involved, this step is not required)

Note: Check-out/Check-in operations are not shown in the piece of code below. If you are performing multiple actions/operations in the project, these actions need not be repeated multiple times. If you want to perform these operations, please refer to the previous article.

The following piece of code helps deleting a task on the project schedule.

Thus we have seen managing tasks using JSOM approach.