Jump to content

How to Query only Projects that have some exact user assigned?

Alex Sknarin

Recommended Posts

Here is a quick example; let's suppose you have the user ID and you need to find out the list of projects he/she has assigned.


session = #<build your session here>

user_id = '805cf360-115e-11e5-ax81-002593f15914'

# This query looks at active projects only
task_query = 'select project.id, project.name, project.full_name from Task where project.status is active and assignments any (resource_id={})'.format(user_id)
ft_tasks = session.query(task_query).all()

for task in ft_tasks:

    project_id = task['project']['id']
    project_code = task['project']['name']
    project_name = task['project']['full_name']
    print(project_code, project_name, project_id)


Link to comment
Share on other sites


Find a list of projects that user X


I have standalone tool that used list of projects that's loaded from Ftrack. I need to show only projects that user is involved in.


If so I would instead query the assignments for the user and find the project from there.

Ah, get from user side. Ok I'll try but I will need to get list of all tasks that artist is assigned to so it could be slower

Link to comment
Share on other sites

If you want to go directly through the project, you can look at its "assignments" key. You can tweak the code above to query Assignment instead of Task.


Although to be fair I'm not sure the "assignments" key in a project will give you assignments for every children. I don't believe the project has assignee so it might work. I haven't tried doing so this way.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...