Only process a ScriptRunner event for certain pages. Edited

I want to use a ScriptRunner event to only process certain pages. I know how to narrow the page down to the space within the ScriptRunner event code, but I only want to process certain pages within the space. Is there a way when creating pages to designate what I'll call a PageType? So when I create a page, I'd like to give the page a PageType I define and then read that value from Groovy.

To help clarify this a little more, I have a space lets call Projects. Under this I have what I call a "Project" page type and under Project page I have a Request page. I want the ability to define each of these page type and be able to use Groovey to determine what each page type is.

(space) Projects

    - Project 1

        - Request 1

    - Project 2

        - Request 2

1 answer

Maybe you could define a label that refers to a specific page type and filter based on that?

I was able to add a Content Property to my pages. My one issue now is how to retrive the Content Property via REST. This is what I have so far but it's not working. I've add log entries to see how far it gets and I get to "eWeb Request Form Event: 2" and then it throws an error on http.get with a Not Found error.

import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.pages.Page

def event = event as PageEvent

Page page = event.getPage()
Space space = page.getSpace()

if (space.key != 'eWebProjects') {
log.warn("eWebRequest Form Save Event - this is not the eWebProjects space")

//import static*
//import static*
//import groovy.json.JsonSlurper
//import net.sf.json.groovy.JsonSlurper

log.warn("eWeb Request Form Event: 1")
def http = new HTTPBuilder('http://confluence/rest/api/')
log.warn("eWeb Request Form Event: 2")
def pageType
def url = 'content/' + + '/property/page-type/'

http.get(path: url,
contentType : 'application/json'
) { resp, reader ->

println reader
log.warn("eWeb Request Form Event: 3")
//pageType = json

log.warn("eWeb Request Form Event: page-type = " + pageType)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Tuesday in Confluence

Confluence Admin Certification now $150 for Community Members

More and more people are building their careers with Atlassian, and we want you to be at the front of this wave! Important Dates Start the Certification Prep Course by 2 April 2019 Take your e...

212 views 2 10
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you