Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Confluence Scrptrunner event handler not working for PageCopyEvent

Hi Guys,

We are trying to get the scriptrunner Confluence event handler working for PageCopyEvent.
Unfortunately the event handler seems to be totally ignored.
Running on the console for a specific page is successful but in in the real system nothing is triggered.
No errors or debugs showing in the logs either.

Even running this basic code, nothing is logged when a page is  copied

import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.methoda.test")
log.setLevel(Level.DEBUG)

 

Our need is to delete certain labels in the target page when a page is copied 

This is the actual  code that  we are trying to run in the end:

import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.event.events.content.page.PageEvent
import com.atlassian.confluence.pages.CommentManager
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.labels.LabelManager
import com.atlassian.confluence.event.events.content.page.PageCopyEvent
import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("logger.test")
log.setLevel(Level.DEBUG)
def labelManager = ComponentLocator.getComponent(LabelManager)

//def pageManager = ComponentLocator.getComponent(PageManager)
//def origin=pageManager.getPage(65723)
//def destination=pageManager.getPage(1114170)

def event = event as PageCopyEvent
def originpage = event.getOrigin() 
def destinationpage = event.getDestination() 
def label = originpage.getLabels()


log.debug("origin: "originpage" destination: " destinationpage " labels: " + label)
for(def item: label){
if(item.toString().contains('syswt_pagepublished') || item.toString().contains('syswt_published-to-'))

{ labelManager.removeLabel(destinationpage, labelManager.getLabel(item)) }

}

log.debug("labels: "+label)

 

Would really appreciate some help with this.

 

Thanks.

 

1 answer

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Do Not Lose your Customer’s Trust

Missing deadlines is one of the biggest problems every team lead wants to avoid when dealing with managed services. When the customer contracts your company to help with IT services it is expected th...

24 views 0 0
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you