[PYTHON API] Querying template task names in a task template entity

Hello all,

I’ve been looking on the web for this answer and it seems like that either it is not possible or I cannot find it.

SCENARIO:
I have “TaskTemplateA”, with a set of the following tasks: “TaskA”, “TaskB” and “TaskC” (as far as I know these are called template tasks, because they are tasks that belong to a Task Template instead of an asset, shot etc.)

MY QUESTION:
How can I programatically get a list of all the tasks that a task template holds if I just have the TaskTemplate name (in this case “TaskTemplateA”)?

I have tried:

sg.find(“TaskTemplate”, filters = [‘code’,‘is’, “TaskTemplateA”], fields = [‘code’, ‘content’, ‘template_task’, ‘task_count’])

But it won’t return the task names.

Thank you for your help,

Kind regards,

3 Likes

I just found a work around…

for item in sg.find("Task", filters = [['task_template', 'is_not', None]], fields = ['content', 'task_template']):
        print("Template Task name = {}; Task Template Name = {}".format(item['content'], item['task_template']['name']))

It looks like you need to filter tasks by those who don’t have any task_template and then get the task template from those.

Kind regards,

3 Likes

Welcome to the community, @j.moraga!

Glad you got it worked out—thanks for taking a minute to report back the solution you found. :partying_face:

1 Like