I am using Python API to update parent tasks when a custom field in the child changes. One case is: When a subtask gets deleted, i substract the custom field value x from the parent.
Therefore i need to know who the deleted task’s parent is. I get the following event from the API when a subtask is deleted:
2022-03-14 10:51:16,887 - INFO - Raw event get:{'data': [{'action': 'deleted',
'created_at': '2022-03-14T03:51:07.098Z',
'parent': None,
'resource': {'gid': '1201926186438985',
'name': 'sample_quotes_lvl2',
'resource_subtype': 'default_task',
'resource_type': 'task'},
'type': 'task',
'user': {'gid': '1201088717130782',
'name': 'john',
'resource_type': 'user'}}],
'has_more': False,
'sync': 'c71784576eb6fb7b86c5f9d4b9fb8743:0'}
‘parent’ is None, even though this was a subtask. Bad. I need the gid of the parent to adjust the custom field values there!
When i add/remove subtasks from parent tasks, the API answer is more verbose and delivers a parent field with gid of the parent, example:
2022-03-14 10:13:27,748 - INFO - Parser: event['action']='removed'(event_handler.py:397){'action': 'removed',
'created_at': '2022-03-14T03:13:21.870Z',
'parent': {'gid': '1201737942764953',
'name': 'Get sample quotes',
'resource_subtype': 'default_task',
'resource_type': 'task'},
'resource': {'gid': '1201926186438985',
'name': 'sample_quotes_lvl2',
'resource_subtype': 'default_task',
'resource_type': 'task'},
'type': 'task',
'user': {'gid': '1201088717130782',
'name': 'john',
'resource_type': 'user'}}
With this information on the parent field, i can successfully update my parent task.
So, why not deliver the parent field with the event if a task is deleted/undeleted? If a task is undeleted, i noticed that it is even automatically reattached to its former parent! So why not specify the parent in the event response? Asana internally knows the parent reference, even on a deleted task…
How can i circumvent this problem? Tried search API, but this doesn’t allow to search for deleted tasks. Any ideas how i can convince Asana API to give me some more information on the subtask’s parent if subtask is: deleted/undeleted? Please!
Best regards,
John