Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script runner for Confluence event handler listening on event from other plugins

Tuelle
Contributor
January 28, 2017

Hi,

I am using the three plugins Script Runner for Confluence, Comalatech Workflows and Metadata (by A.Armstrong). Is it possible to write an event handler with Script Runner that listens on

  • events implemented by Comalatech Workflows (e.g. ContentApproveEvent or StateChangeEvent), or
  • events related to metadata fields? 

Thanks for any answer!

3 answers

3 votes
Rafael Franco
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 21, 2017

Hi Tuelle,

Was thinking how you could solve this. Took me a while since I had to actually decompile the Comala Workflows add-on and understand how they do it. The good news is that there is sort of a way that you can fix this.

You'll need to use the Script Listeners and listen to the PageUpdateEvent.

Every time a Approval/Rejection or whatever state is performed, the PageUpdateEvent will be fired. This means you can actually catch the event, verify if it comes from Comala, and add a contentProperty stating the initial version using

this.contentPropertyManager.setStringProperty(page, "versionBeforeApproval", currentPageVersion);

Then when it's approved, you'll get the same PageUpdateEvent. There you'll need to check for the Approved state as it is shown on the following screenshot:

Screen Shot 2017-02-15 at 16.26.30.png

Then, I would suggest you add another contentProperty issuing the version after the approval.

This means you'll end up with 2 content properties, one that defines the beginning and the other the end.

Finally, you can display those in the UI using a Script Fragment that just calls the following REST Api:

https://docs.atlassian.com/atlassian-confluence/REST/latest/#content/

{id}

/property-findByKey

Hope that helps.

Rafael

Tim
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 15, 2018

Hi Rafeal, is this still the way to do it? I set up a script listener in Scriptrunner and I am listening to the PageUpdateEvent, which does trigger when I edit the page. However, there seems to be no PageUpdateEvent fired when approving a draft via Comala.

 

Thanks,

Tim

1 vote
Rafael Franco
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2017

@Jamie Echlin [Adaptavist] I believe Metadata fields comes from the Metadata add-on

If it fires events then https://productsupport.adaptavist.com/browse/SRPLAT-96 should cover it anyways.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 3, 2017

Unfortunately not currently for the first point: https://productsupport.adaptavist.com/browse/SRPLAT-96

For the second point @Rafael Franco [Adaptavist] can you help please? I'm not sure what a metadata field is in this context.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events