The CompleteTask function is called when a user marks a task as complete. It changes the status of a task to Complete and returns a result code of SUCCESS or FAILED.