Searching on "Date Modified" property returns records from other tables
When I perform a search for records in a table that have the "Modified Date" property between two dates, records from tables other than the one used for the search are returned. The mistaken records' .table
property incorrectly list the selected table.
def get_recently_modified_records( table: granta.Table, minimum_date: str, maximum_date: str, ) -> list[granta.Record]: utils.logger.info( f"Getting records modified between {minimum_date} and {maximum_date}" ) modified_criterion = granta.SearchCriterion( granta.PseudoAttributeDefinition("modifiedDate"), # type: ignore "BETWEEN", (minimum_date, maximum_date), ) return table.search_for_records_where([modified_criterion, table_criterion])
Adding a new criterion for the table returns an error stating that the table name psuedo attribute cannot be used for searching.
table_criterion = granta.SearchCriterion( granta.PseudoAttributeDefinition("tableName"), # type: ignore "CONTAINS", table.name, )
Answers
-
@Doug Addy - this is actually a Granta Q - I have added tags, but can you assist?
0 -
Hi Clay. This should be resolved in Scripting Toolkit v4.0, released with MI 2024 R2. Searching a table with a pseudo-attribute-based criterion now only returns results from that table.
1 -
Thank you, Andy!
Does STK v4.0 work with Granta MI 2024 R1?0 -
Hi Clay,
As a quick workaround for this issue you could add a "dummy" search criterion for an attribute that is always populated, like tb.attributes["ATTRNAME"].search_criterion(exists=True).
For me, the search_records_where()-method then only returns records from the correct table. At least until STK4.0 is released :-)Hope this helps & bests,
Daniel0 -
@Clay Records said:
Thank you, Andy!
Does STK v4.0 work with Granta MI 2024 R1?Yes, 4.0 will be backwards compatible as far as 2023 R1
0