Get verbose information when task is deleted

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

1 Like

Bump.

I don’t know the Events part well, but if it is like webhooks, the philosophy is to not give many details in the payload and let you request the API yourself to get that info. Correct @Phil_Seeman ?

1 Like

Hello Bastien,

Yes, in this special case its problematic though, because i can’t request a deleted task via API, right? So how to find out what its parent is (was) at the moment of deletion?

Yeah. :slightly_frowning_face: :cry: Bastien is right, but so are you here.

I don’t know of a solution other than a full and constant sync of data to an external store on your end, so that when you get the deletion, you can look in your own data store to know the parent. But IMO that’s an awful solution just for this use case, if you don’t need your own synchronized store for other purposes.

@AndrewWong are we missing any solution here? @Frederic_Malenfant or @JFrentz, any ideas?

2 Likes

I tought it could be possible to get some details by reading the “stories” of the parent, but I found that, when we add or remove a subtask, the parent “stories” are not affected.

Only the “modified_at” field change, that’s fine to allow us to refresh or local cached copy, but we don’t have any details in the stories of what happen at that time.

So, it’s a little bit strange that, the “modified_at” field can be “2022-03-13T14:02:00Z”, and the most recent story is “2021-11-15T13:22:00Z”" !!

Something happened to your task that make the modified_at date change, but, we don’t tell you what it is!

1 Like

Yes Frederic,

i also tried parsing the stories but this didn’t solve the problem. If there is no known solution except building a database of the tasks, i will do so for now. It’s cumbersome and worrying, because it could be much easier, therefore i would like to suggest for the next API update:

Please make it possible for deletion/undeletion event of a task X to include the parent task gid of task X.

Why is this important? A lot of tools will have summary features, e.g. summing up the workload of subtasks into the parent task. Therefore we need to identify and update the parent by the emitted event when a subtask is added/removed (works), updated (works) or deleted/undeleted (not working).

I appreciate your answers, and if someone still finds a better workaround, please let me know. And if possible, change the next API to natively support it :wink:

1 Like

Just bumping this to see if this will included in the release?

I don’t work for Asana, I’m just a third-party developer, so I can’t say whether or when they might be making any changes here. (IMO I wouldn’t hold my breath waiting for it if I were you, but that’s just my feeling about it.)

Oh excuse, Phil, i thought you work with Asana :sweat_smile:
Do you know who’s is the right person to address API change requests though?

Thanks!

@AndrewWong maybe?

2 Likes

@AndrewWong

Can you include this in the next Asana release?

Please contact me for any further input.

Thank you!