Shotgrid API filtering Tasks

Hello!

I’m having troubles querying Tasks in a specific Pipeline step. I’m using the following code, which should return all Tasks in of the specific Shot in a specific Sequence in a specific Project. The returned tasks should be in Animation Pipeline Step, or named Previs01.
However this only returns the Previs01 while there are obviously other Tasks in Animation Pipeline Step.
I also tried some variation, but I could only get ALL the tasks or none of them. Any helpful ideas?
(Smaller problem, but also annoys me: the ‘step’ field is not returned.)

        tasks = sg.find("Task", [
            ['project.Project.name', 'is', project_name],
            ['entity.Shot.sg_sequence.Sequence.code', 'is', sequence_code],
            ['entity.Shot.code', 'is', shot_code],
            {
                "filter_operator": "any",
                "filters": [
                    ['step.Step.code', 'is', 'Animation'],
                    ['content', 'is', 'Previs01']
                ]
            }

        ], ['id', 'step', 'content'])

Actually it seems like querying by Pipline step doesn’t work at all. Were there any changes recently in SG API or what am I missing?

Hi Simon,

I’ve run your query on my end and can confirm that it is working correctly.

It’s possible that your issue may be caused by your Task entities not being linked to the “Animation” Pipeline Step or perhaps there’s a possibility that you have multiple Pipeline Step entities that are labelled “Animation”, this could cause the query to be trying to get the incorrect Pipeline Step.

In order to test this, would you be able to get the ID of the “Animation” Pipeline Step that you are wanting to retrieve and then update your query to filter by the Pipeline Step ID instead of the Pipeline Step Code?

tasks = sg.find("Task", [
            ['project.Project.name', 'is', project_name],
            ['entity.Shot.sg_sequence.Sequence.code', 'is', sequence_code],
            ['entity.Shot.code', 'is', shot_code],
            {
                "filter_operator": "any",
                "filters": [
                    ['step.Step.id', 'is', animation_step_id],
                    ['content', 'is', 'Previs01']
                ]
            }

        ], ['id', 'step', 'content'])
1 Like

Hello Michael!
Thanks for the reply. Using the id doesn’t yield better results neither, I’ve already tried that.
Maybe this is an issue with our Shotgrid somehow, I just don’t know how…

Best way to troubleshot now is to explicitly try a find_one for a task that you know should show up in the results, with the field names from your filter.

See if the output is as required.

1 Like

Thanks for the replies!
Unfortunately more important tasks came up, so I’ll continue with this later.

I tried both of your suggestions, and I’ve got some strange results:

As I stated above, filtering with id doesn’t solve this for me: it results ALL the possible tasks, not just the ones for the filtered step.

As for the find_one: I can find the task, but if I add ‘step’ for the fields, it’s just ignored. I won’t get back the task’s step in any way. I double checked: the Task entity has a field with field code ‘step’.

I have no idea why this is happening. :confused:

I have tried this as well and cannot replicate your problem.

Best to put a ticket in with support in this case!

Contact Customer Support | Autodesk Knowledge Network

2 Likes

Feels stupid, but the problem lied in the script users’ insufficient permissions: couldn’t see the Tasks’ Pipeline Step fields.

Case closed.

2 Likes