Hi! This is a fragment of my script, it creates several child containers, and every child container includes it's own dynamic query.
for site in SitesList:
child_group_id = swis.invoke('Orion.Container', 'CreateContainerWithParent',
ParentGroupID,
site+ChildGroupName, # Group Name
'Core', # Child owner, must be 'Core'
600, # Refresh frequency in seconds
StatusMode,
site+ChildGroupDescription, # Child Description
False, # Polling disabled
[
{'Name': site+' query',
'Definition': "filter:/Orion.Nodes[CustomProperties.City='"+site+"]"},
]
)
Every node in our Orion have a custom field "City", which is corresponds to certain city codes ("BUH", "NYC", "BOS", etc).

So logic is very simple: there is a parent group with a set of child groups (child group names are determined by location area too: "BUH ALL", "NYC ALL", "BOS ALL", etc): "BUH ALL"-group includes all nodes with custom field City = BUH, "NYC ALL" includes all nodes with custom field City = NYC, etc
And the problem is: after creating a dynamic query with my code, I see what child group includes not only "%City% ALL"-nodes, but all nodes at all.

If I manually open this query (by clicking edit properties) I see a proper rule.
And "preview" button shows me only %SITE% nodes. As it should be.
And if I press |save| button, everything sets back in its place:

But I have many locations, I can't click "save" for every rule
How to fix this?