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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • 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

Looking to automate deleting pages with a specific label...

Hello - we are running (server) Confluence with Comala Document Management and Scriptrunner.

There is an archival workflow that manages pages such that after a year of inactivity they are flagged for review and if no action is taken they are then flagged for removal.

Comala Document Management does not have the capability to delete pages.  The most I can do is restrict them and add a label "to-be-deleted". 

Scriptrunner appears to have to the theoretical ability to run a script, on a schedule, that will look for all pages with a specific label (i.e. to-be-deleted) and delete said pages.

I have a small script in Scriptrunner that will find and return the ids of all pages with a specific label - what I have not been able to find is how to delete pages in a Scriptrunner script.

1 answer

Hi Jason! 

It sounds like you're almost there with your script so I'll just add the snippet displaying how you can send a single page to the trash. 

The Page Manager contains the method Trash Page which will accept the ids of the page you have already fetched as well as a Delete Context.  

You can view an example of how this is used below:

import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.core.DefaultDeleteContext

def pageManager = ComponentLocator.getComponent(PageManager)
def pageToDelete = pageManager.getPage(<page_id>)

pageManager.trashPage(pageToDelete, DefaultDeleteContext.DEFAULT)

Kind regards,  

Suggest an answer

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

Announcing Team Calendars in Confluence Data Center

Hi Community! We're thrilled to share that Team Calendars for Confluence is now a built-in feature for Confluence Data Center releases 7.11 and beyond.  A long time favorite,  Team Cale...

198 views 0 6
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