I am preparing an ArcGISProject, a layout and its elements within a python toolbox (.pyt). When the layout contains a TableFrameElement (CIMTableFrame) and the referenced map a selection, I try to apply a CustomWhereClause on the TableFrameElement in order to reflect the map's selection in the table. This works fine when the TableFrameElement.Query is set to VISIBLE_ROWS. However, if the TableFrameElement.Query is set to ALL_ROWS the custom where clause does not seem to apply when exporting the layout and the table just ignores it.
It is quiet good observable when opening the working ArcGISProject. The CustomWhereClause is not applied to the TableFrameElement if Query is set to ALL_ROWS. After clicking around in the project (opening the map, zooming to a layer, reapply the same query, etc.) suddenly the query is applied. So there is an update trigger missing somewhere?
The CustomWhereClause is successfully applied to the TableFrameElement if Query is set to VISIBLE_ROWS.
Whats confusing is that the doc says for the CustomWhereClause...
Gets or sets the custom where clause. Show rows that match custom where clause when FillingStrategy is set to esriCIMTableFrameFillingStrategy_CustomWhereClause.
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic19955.html
On the CIM level I can apply the FillingStrategy, but after applying it with setDefinition, the TableFrameElement.Query remains. According to the docs, the TableFrameElement does not seem to support the new FillingStrategy, but it is present on the CIM level.
https://pro.arcgis.com/en/pro-app/3.3/arcpy/mapping/tableframeelement-class.htm
So I guess there seems to be a bug or the feature is not fully supported yet. Any help would be appreciated!
That's definitely a weird one. If you're having issues modifying the CIM using updateDefinition, you can always just unzip the aprx, find the table frame json file, and change the value manually before re-zipping and renaming it to .aprx
It's a very hacky workaround, but I've done it before when the public API doesn't work or works in a weird way.
That is essentially what the updateDefinition function does anyways, the CIM is stored in a plaintext json directory structure. You may run into issues editing the project file while it's open though.
Thanks for your response, I just checked the unzipped .aprx and everything seems just fine. The TableFrame referring to the correct map/layer and has the proper customWhereClause applied. I think the state of the CIM is fine.
The customWhereClause getting applied after doing some stuff in the project (opening the map, zooming to a layer, reapply the same query, etc.). The CIM definitions are also identical before and after, so I am pretty sure that there is some sort of event/trigger/refresh missing when applying it for this specific case.
It does seem that CIMTableFrames use ShowAllRows as the default flag for fillingStrategy, but CustomWhereClause is available in the enum:
Have you tried to set the fillingStrategy attribute of the TableFrame to 3/TableFrameFillingStrategy.CustomWhereClause?