How do I filter tasks by extended properties? #1201
-
I have this code which has several different extended properties. However, due to the shear amount of items in this folder, it takes forever to retrieve each and every item, with their respective extended property. How would one filter items based on extended properties to decrease runtime? In the following code I defined several extended properties. I want to filter the items in the tasks variable by the client name. So for an example I want to filter all the items by only retrieving items with the ".Client" extended property, and only if the extended property is equal to the string "BUCK". How would I achieve this? # Define extended property .Status
class status(ExtendedProperty):
distinguished_property_set_id = 'PublicStrings'
property_name = '.Status'
property_type = 'String'
# Register the extended property on the task item type
Task.register('status_property', status)
# Define extended property .Client
class client(ExtendedProperty):
distinguished_property_set_id = 'PublicStrings'
property_name = '.Client'
property_type = 'String'
# Register the extended property on the task item type
Task.register('client_property', client)
# Define extended property .Client
class assignee(ExtendedProperty):
distinguished_property_set_id = 'PublicStrings'
property_name = '.Assignee'
property_type = 'String'
# Register the extended property on the task item type
Task.register('assignee_property', assignee)
# Define extended property .HrsBillableTotal
class hrsbillabletotal(ExtendedProperty):
distinguished_property_set_id = 'PublicStrings'
property_name = '.HrsBillableTotal'
property_type = 'Double'
# Register the extended property on the task item type
Task.register('hrsbillabletotal_property', hrsbillabletotal)
# Define extended property .HrsBillableTotal
class cause(ExtendedProperty):
distinguished_property_set_id = 'PublicStrings'
property_name = '.cause1'
property_type = 'String'
# Register the extended property on the task item type
Task.register('cause_property', cause)
# Define extended property .SystemTime
class datelastactivity(ExtendedProperty):
distinguished_property_set_id = 'PublicStrings'
property_name = '.DateLastActivity'
property_type = 'SystemTime'
# Register the extended property on the task item type
Task.register('datelastactivity_property', datelastactivity)
# Fetch task items in the subfolder
tasks = subfolder.all() |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
When you have registered an extended property, you should be able to use it like any other field: class SomeExtProp(ExtendedProperty):
...
Task.register('some_ext_prop', SomeExtProp)
for task in account.tasks.filter(some_ext_prop="something"):
print(task.some_ext_prop) |
Beta Was this translation helpful? Give feedback.
When you have registered an extended property, you should be able to use it like any other field: