0

Google says that setStatus property for the Tasks can be 'completed' and 'needsAction': https://developers.google.com/apps-script/class_tasks_v1_schema_task#setStatus

I'm using the API with the PHP library. When I insert a new task, I can set the status to 'completed' or 'needsAction'. But when I edit a task, if the task is already set as 'completed', I can't set the status to 'needsAction'.

So, the update works from 'needsAction' to 'completed', but not the other way. Directly on the web you can change the status however you like.

Anyone else with the same issue?

Andrej
  • 415
  • 1
  • 7
  • 25

2 Answers2

4

You also need to set the completedDate to null.

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
  • One other question regarding the completed date. Why do we need this field, when it is not shown in the calendar on the web? We can see that the task is marked as complete, but not when. – Andrej Oct 01 '13 at 12:45
  • I guess Google put "stuff" into the Tasks API and underlying data model, that the their Web UI designers decided they didn't want to use. It's easier to have stuff in the model that is unused, than to have to modify the model down the road to include additional fields. – pinoyyid Oct 01 '13 at 13:15
1

Hell, it took me an hour to solve this problem. Your PHP code should look like the following for it to work:

$task = new Google_Service_Tasks_Task();
$task->setCompleted(Google_Model::NULL_VALUE);
$task->setStatus('needsAction');
$service->tasks->patch($params->tlid, $params->tid, $task);

note the special Google_Model::NULL_VALUE which is documented here

Ramon
  • 49
  • 5