0

Retrieve Tasks (content) in TaskTemplates via python API

Hello, I can't find a solution to retrieve these information in this order.

1st request is ok :
fields = ['code', 'tasks', 'sg_project', 'entity_type']
filters = [['sg_project', 'is', {'type':'Project', 'id': project}], ['entity_type', 'is', 'Shot']]
task_list = sg.find("TaskTemplate", filters, fields)

now I need to list the names (content) of that particular Tasktemplate

Thanks

6 comments

  • 0
    Avatar
    Brandon Foster

    Hi Remy,

    Good question, I'll be happy to look into this for you. What's your ultimate goal with your script? Are you trying to manage Task Templates and the Tasks which they contain all through script rather than the Shotgun web UI?

  • 0
    Avatar
    Remy Crissan

    Hello Brandon, absolutely not but it may be a future feature and I see the potential of that kind of feature.

    The aim of my script is to check the tasks of a TaskTemplate and check with AWS S3 backup, so backup script could automatically check the backups by TaskTemplate. And save some cpu in my backup script.

    That's all :)

  • 0
    Avatar
    Brandon Foster

    Thanks for the additional info Remy. After speaking with our engineers we currently do not provide a way to see which Tasks belong to a Task Template via the API. There's some deeper associations which are not currently exposed and would need to be treated as the development of a new feature here.

    As a side note, we perform backups every 24 hours so your site is protected in the event of some catastrophic incident. If that covers your needs for creating a backup, doing your own shouldn't be necessary.

  • 0
    Avatar
    Ryan de Kleer

    Did this ever become a feature request?  There are 30 pages of requests in the above link, and no way to search them.

  • 1
    Avatar
    Brandon Foster

    Hi Ryan,

    Doing some searches it doesn't appear so. It does appear I was mistaken in that there was no way to do this. During my search I found this old thread:

    https://support.shotgunsoftware.com/hc/en-us/community/posts/209488098-Adding-Tasks-to-TemplateTasks-via-API

    Reversing the creation logic, you could perform a find like so:

    >>> sg.find('Task', [['task_template', 'is', {'type':'TaskTemplate', 'id':4}]], ['code'])

    The task_template field is not one we expose in the UI, which is why I missed that before. Let me know how that works for you.

  • 0
    Avatar
    Ryan de Kleer

    Spot on, thanks Brandon.  I was getting an empty list before but it turns out that was because I was also filtering by project -_-

    Thanks!

Please sign in to leave a comment.