Jump to content

new API : get all task and assignements


manu

Recommended Posts

Posted

Hi ! 

I'm trying to get all project's tasks with users assignated to them in the less possible query. 

session = ftrack_api.Session()
tasks = session.query('Task where project.full_name is "' + projectName + '" ').all()   
session.populate(tasks, 'name,status.name,assignments.context.name' )

for task in tasks : 
    with session.auto_populating(False) :
        if len(task['assignments'])> 0 :
            print( task['assignments'][0]['resource'] )

I get this : 

<Appointment(9c76e170-f0d6-11e5-861a-42010af00076)>

But when I try to get ressource attribute value from this, it's empty. 
str( task['assignments'][0]['resource']) return "NOT SET",
That must be caused by auto_populating(False)

So perhaps I need to modify my query ?
Cause if I remove auto_populating(False), I'm afraid that is gonna be slow;

Best regards 

 

Posted

You could try session.populate(tasks, 'name,status.name,assignments.resource') instead. I know if you use assignments.resource.name it will break even though it seems like it should be valid. So you can always add name as a default projection for Task similar to this example: Default Projections

Posted

Hi eight !

Thanks for your answer. I tried various method to get (in one query) task, task name, task status and assignated users using projection, but I wasn't able to make it works... 

This is the same problem with the custom attributes. 

If someone have an code example to show how to do that, I would be very happy :)

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...