Use automation to check page last udpate
Asked by Jiecai.Peng:

Hi Community,

I am trying to create an automation rule that checks whether a Confluence page has been updated within the last hour. I attempted to use a schedule trigger with CQL, but discovered that the schedule trigger in Confluence automation does not support queries.

Is there another way to accomplish this task using Confluence automation?

Appreciate your help


Answers:
author: Trev Angle
body: Hi [@Jiecai.Peng](/t5/user/viewprofilepage/user-id/5178158) Trevor here from the Confluence automation team. Here is a working example of an automation rule that logs the titles of pages edited within the last hour:

![Screenshot 2023-04-03 at 11.44.00 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/249539i890142F96123C763/image-size/large?v=v2&px=999 "Screenshot 2023-04-03 at 11.44.00 AM.png")

If you want to access info about the page through smart values, the 'related entities' branch outputs the {{cqlResult}} smart value, which supports these fields:

* {{cqlResult.title}}
* {{cqlResult.type}}
* {{cqlResult.status}}
* {{cqlResult.id}}

If you need to access other smart value fields, we may be able to find a workaround. Just let me know!

Also, if your use case allows it, I would recommend you run the rule less frequently than every hour. If there is any delay in the rule executing, then it is possible for some piece of content that was updated exactly 60 minutes ago to slip through the cracks. For example, you could do the same rule but have it run every day and update the CQL like so: type = page AND lastmodified \> now("-1d")


author: Aron Gombas _Midori_
body: [@Jiecai.Peng](/t5/user/viewprofilepage/user-id/5178158) We have built an app that supports custom notifications in a super-flexible way.

You can define a flexible schedule, a CQL query, customize the email template and choose the recipients like this:

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

The CQL query in your case would be:

```
updated > now("-1h")
```

Would this meet your requirements?


author: Riley Venable
body: Yes, there is another way to accomplish this task using Confluence automation. You can use the "Page updated" trigger and add an action to check if the page has been updated within the last hour. You can do this by adding a "Branch" action and setting a condition that checks if the page was updated within the last hour using the "Page updated date" variable and the "Current time" variable. If the condition is true, you can add an action to perform the desired task.

comments: author: James Totah
body: Have you had success with this Automation [@Riley Venable](/t5/user/viewprofilepage/user-id/4584007) I believe Im getting the same error.

CQL condition  
Error in execution:  
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.

![Screenshot 2023-03-27 at 10.26.35 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/247969i646240FB3D96732F/image-size/large?v=v2&px=999 "Screenshot 2023-03-27 at 10.26.35 AM.png")


author: Trev Angle
body: Hi [@James Totah](/t5/user/viewprofilepage/user-id/5175746) I believe that rule will work if you replace the 'CQL condition' component with a 'Branch rule / related entities' component (and use the same CQL query).

The 'CQL condition' is a *filter*, it is used to stop or continue the rule execution based on the properties of the CQL content that last appeared in the rule. In the case of a scheduled trigger, there is no particular content to check against the CQL query.

The 'related entities' branch is more like a *search mechanism*, it allows you to find any piece of content you want based on the CQL query. In this case it looks like that is what you're looking for.


author: James Totah
body: It worked! Thank you!


Tags: automation

cloud

confluence-cloud