Confluence Automation | CQL Error
Asked by Claudio Palmeri:

Hi Community,

I am trying to run a Confluence Automation script, to identify all pages in my space that have a specific label attached to them, and apply a page restriction.

This script would be a one-off run to restrict all pages that already have the label.

There is then a second script that restricts pages as the label is applied.

The first script (one-off) throws an error, even though the CQL seems to validate fine. See below.

CQL: *type="page" and label="100"*

CQL validation: *valid query. 1 contents found*

Error when running script: *No CQL-compatible content found in the rule context; there is nothing to check against the CQL query. The CQL condition component can only follow components that involve CQL-compatible content, such as the blogpost published trigger, the publish new page action, or the related entities branch.*

Any suggestions?


Answers:
author: Aron Gombas _Midori_
body: Can you take a screenshot about the complete rule including the trigger? Trim down the rule to simplest configuration that can be used to reproduce the problem.

comments: author: Claudio Palmeri
body: Here it is, including error message.

![automation_error.png](https://community.atlassian.com/t5/image/serverpage/image-id/280193i7CBE549B4F442F5C/image-size/large?v=v2&px=999 "automation_error.png")


author: Mike Monk
body: My guess is that it doesn't know what to match the query against as there is nothing selected to compare.

You might need to add a query to select all pages published in the last 24 hours and then check the field


author: Claudio Palmeri
body: Thank you, Mike. It's strange though that when I validate the query, it does find the 1 match (which is correct, in this sample Space).

I will try to further modify the query...


author: Aron Gombas _Midori_
body: [@Claudio Palmeri](/t5/user/viewprofilepage/user-id/4890149) We have an automation that also runs a CQL search periodically, but we use a different component, not the "if" block.

Can you try the "Branch rule / related entities" block?

(Otherwise I totally agree with [@Mike Monk](/t5/user/viewprofilepage/user-id/4898230)'s idea what is the actual root cause in your case.)

![Confluence.png](https://community.atlassian.com/t5/image/serverpage/image-id/280320iB3C3E285EE658A79/image-size/large?v=v2&px=999 "Confluence.png")


author: Mike Monk
body: I have had a further play and came up with the same solution as Aron.

[@Aron Gombas _Midori_](/t5/user/viewprofilepage/user-id/502447) did that add the action to each page?


author: Aron Gombas _Midori_
body: I am not sure that I understand the question...

But if you asked if the rule configured this way processes all pages and each page separately, then the answer is yes. It actually works for me (prints the page names one by one to the audit log).


author: Mike Monk
body: Sorry it was badly worded, but yes did the action happen for every page in the initial query :)


author: Claudio Palmeri
body: Hi [@Aron Gombas _Midori_](/t5/user/viewprofilepage/user-id/502447) and [@Mike Monk](/t5/user/viewprofilepage/user-id/4898230) - confirming that I was able to run the automation rule using the **Branch rule / related entities** construct and restrict page successfully! Thank you for your help with this!


author: Aron Gombas _Midori_
body: I don't think that it is the root cause, but technically you don't the quotes around the content type. Your query should be like this:

```
type=page and label="100"
```

comments: author: Claudio Palmeri
body: Thank you for the response.

I have tried with and without the quotes. Using uppercase AND. Putting the whole thing in round brackets.

The validation always works (it's correct, in the test space there is only 1 page matching the criteria), but then when I run the script it fails...


Tags: cloud

confluence-cloud