Email Notification on Page Activation | Community
Skip to main content
gabrielav200407
Level 2
October 16, 2015
Solved

Email Notification on Page Activation

  • October 16, 2015
  • 5 replies
  • 1754 views

I want to send an email notification wen a page is activated, but there are also modifications since the last activation.

For now, we have implemented an event handler that detects the ACTIVATE events.

Is there a way to check if the page has also been modified since the last activation?

 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by edubey

You can keep a custom property to track activation date, now when ever you are activating a page,  compare last modified property and custom property ( last activation date). If last modified is greater than last activate date, it means page has been modified and then update this property with new activation date.

5 replies

edubey
Level 10
October 16, 2015

You can read the cq:lastmodifieddate date property of that page stored in jcr:content

gabrielav200407
Level 2
October 16, 2015

How will that help me? if I activate the same page twice, the last modification date stays the same, while the activation date changes, so my event handler is triggered. How do i know that the modified date changed between two activations?

edubey
Level 10
October 16, 2015

Use getPath() to check which property gets changes and add PROPERTY_CHANGED  changed event on the node path

if cq:lastmodified  changes, getPath() will return something similar to  path will be [node path]/cq:lastmodified

http://www.day.com/specs/jsr170/javadocs/jcr-1.0/javax/jcr/observation/Event.html#getPath()

gabrielav200407
Level 2
October 16, 2015

But the event i'm listening to is the activate event, not the PROPERTY_CHANGED event. I need to detect the activation events in order to trigger notification emails.

edubey
edubeyAccepted solution
Level 10
October 16, 2015

You can keep a custom property to track activation date, now when ever you are activating a page,  compare last modified property and custom property ( last activation date). If last modified is greater than last activate date, it means page has been modified and then update this property with new activation date.