Alex Sknarin Posted May 7, 2021 Report Share Posted May 7, 2021 Hello I could assign user to a task using this method http://ftrack-python-api.rtd.ftrack.com/en/stable/example/assignments_and_allocations.html But what should I do to UN-assign user from task? Link to comment Share on other sites More sharing options...
Yas Opisso Posted May 7, 2021 Report Share Posted May 7, 2021 Hi, You essentially have to delete the user assignment, here's a function below that removes all users given a specific task_id, it might not be exactly what you need since you might only want to remove a specific user but this should point you in the right direction. # Assumes a session is already established def unassing_users_from_task(task_id): # Queries users assigned to a task users_assigned_to_tasks = session.query( 'select assignments.context_id from User ' 'where assignments any (context_id = "{0}")'.format(task_id) ) for user in users_assigned_to_tasks: assignments = user['assignments'] for assignment in assignments: if assignment['context_id'] == task_id: session.delete(assignment) # Remember to use session.commit() I would only do this if you had in fact removed an assignment. session.commit() Link to comment Share on other sites More sharing options...
Alex Sknarin Posted May 10, 2021 Author Report Share Posted May 10, 2021 thanks i'll dig into it Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now