Automation not executed even if CQL query test successful
Asked by tfellinger:

I've created an automation that runs when a new page is created. I've tried the "if" block and later also tried the "branch rule" conditional to check if the page is under a certain section (I've tried parent and ancestor). If it is, I want to receive a notification using Slack.

![Automation_Overview.png](/t5/image/serverpage/image-id/290051i101231A1BD19DB48/image-dimensions/187x311?v=v2 "Automation_Overview.png")

Problem is, even if the query matches here, the automation is not finding the newly created page. When I open the Automation and check the query builder again it still matches the pages correctly (when I add one the counter gets incremented correctly).

![Automation_Query.png](/t5/image/serverpage/image-id/290052iC5803D83C4651570/image-dimensions/440x165?v=v2 "Automation_Query.png")

I have no idea why this happens...to me it looks like a bug, but I don't have a ton of experience with Confluence Automations so maybe I'm doing something wrong as well. In the audit log I see that the shown evaluated query is exactly the one I use in the CQL selection, but weirdly with an additional AND space in ("foobar").

![Automation_Audit_Log.png](/t5/image/serverpage/image-id/290053iED6AE8A4B492BFD6/image-dimensions/638x100?v=v2 "Automation_Audit_Log.png")

Any hints how I can further troubleshoot this or maybe even how to fix it?

Thanks!


Answers:
author: Aron Gombas _Midori_
body: [@tfellinger](/t5/user/viewprofilepage/user-id/5356615)

**The problem**

We experience it every day that CQL queries have a few-second latency. If you create a new page or update an existing one (e.g. by adding labels) queries *will* not return them for awhile. If you wait for 10 seconds, and repeat the query that it will finally return the page!

Atlassian has never explained it, but we think that the search indexes that CQL relies on require a few second to reflect the changes. Until they become consistent again, they may return outdated result (basically the one that relies on the state *before* the change).

**The solution**

In your case, you could try if waiting for 10 seconds before you try the CQL will resolve the problem.

(You can wait and block the execution of the automation rule for N seconds by sending a request to an external site which waits for N seconds before responding. I know that there are sites that provide this "functionality".)


author: Kseniia Trushnikova
body: Hi [@tfellinger](/t5/user/viewprofilepage/user-id/5356615),

I can also reproduce the issue with CQL. Try to use *Advanced compare condition* instead of CQL:

```
{{page.parent.id}} equals PAGE_ID
```

This should work. Here's the rule example:

![Confluence Automation - Advanced compare condition.png](https://community.atlassian.com/t5/image/serverpage/image-id/290154iAFC084DF14FCDDD7/image-size/large?v=v2&px=999 "Confluence Automation - Advanced compare condition.png")

I've found the bug ticket <https://jira.atlassian.com/browse/AUTO-699> that looks related to the issue you have. Please click *This affects my team* to increase the bug visibility.

Hope it helps.

comments: author: tfellinger
body: Thanks [@Kseniia Trushnikova](/t5/user/viewprofilepage/user-id/4593830) !

The automation now triggers successfully. The only thing missing now is that I want to notify on all levels of sub pages and if I understand that correctly the "page.parent.id" only acts on the direct parent page as opposed to the "ancestor.id" that would work on all levels of parents, right?

Any way how to make that work with the advanced compare condition you're aware of?

Thanks again for the fast and helpful response!


author: Kseniia Trushnikova
body: [@tfellinger](/t5/user/viewprofilepage/user-id/5356615), yes, {{page.parent.id}} only refers to the parent page.

I can't find any smart values for ancestors in the documentation [Smart values in Confluence automation](https://support.atlassian.com/cloud-automation/docs/smart-values-in-confluence-automation/)... None of them work: {{page.ancestor}} {{page.ancestor.id}} {{page.ancestor.url}}

Seems like smart values for ancestors are not added yet.

Though I'd recommend you to contact the Atlassian support regarding this. I may be missing something.


Tags: cloud

confluence-cloud