Note Relationship
1 1

2 posts in this topic


What is the best relationship we can use to extract notes from a task in a query?

for example:

something like,

note = session.get('Note where content is "xyz" and is "something"'.one())

P.S.: I don't want to use 'ID' for extracting particular note.


Thanks in advance,

Share this post

Link to post
Share on other sites


There is no `parent` relationship on notes due to a technical limitation and the fact that notes can be written on multiple entity types (such as tasks or versions). You can work around this issue by rephrasing the query to start with tasks and using the notes relationship.

See the example below:

note_content_contains = 'xyz'
task_name = 'something'
tasks = session.query(
    'select notes.content from Task '
    'where notes.content like "%{0}%" and name is "{1}"'.format(
        note_content_contains, task_name

for task in tasks:
    for note in task['notes']:
        print note['content']


If you want to include notes on other objects, such as Folders or Shots, change `from Task` to `from TypedContext`. TypedContext is the name of a base entity type which can be used to query all objects in a project hierarchy.


Share this post

Link to post
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
1 1