How do you correctly add permissions to a page using Scriptrunner for Confluence Edited


I'm trying to write a script that applies all the edit-permission of one page onto all of it's descendants.
I have 2 problems when running my script:

  1. The permissions get applied only to the lowest level of pages in the hierarchy
  2. When removing a permission from the original page after running the script I'm unable to save the change and after a while the page get's corrupted and I can no longer view it. I only receive the following error:


    org.hibernate.ObjectNotFoundException: No row with the given identifier exists: []
        at org.hibernate.boot.internal.StandardEntityNotFoundDelegate.handleEntityNotFound(

    Stack Trace:[hide]

    org.hibernate.ObjectNotFoundException: No row with the given identifier exists: []
    	at org.hibernate.boot.internal.StandardEntityNotFoundDelegate.handleEntityNotFound(
    	at org.hibernate.event.internal.DefaultLoadEventListener.load(
    	at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(
    	at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(


Following is my code:

import com.atlassian.confluence.core.ContentPermissionManager
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.sal.api.component.ComponentLocator
import groovy.json.JsonOutput
import groovy.transform.BaseScript


@BaseScript CustomEndpointDelegate delegate

copyRestrictionsToDescendants() { MultivaluedMap queryParams, String body ->
def pageId = queryParams.getFirst("pageId") as long// use the pageId to retrieve this page
def pageManager = ComponentLocator.getComponent(PageManager)
def permissionManager = ComponentLocator.getComponent(ContentPermissionManager)

def currentPage = pageManager.getPage(pageId)
def editPermissions = currentPage.getContentPermissionSet(ContentPermission.EDIT_PERMISSION)

def addPermissions

addPermissions = { List<Page> pages ->
for (Page child : pages) {
for (ContentPermission permission in editPermissions) {
permissionManager.addContentPermission(permission, child)


def flag = [
type : 'success',
title: "Requirement bar added",
close: 'auto',
body : "The requirement bar has been added."



1 answer

Hey Terje,

In ScriptRunner for Confluence we have a built-in script that allows you to do just this! If you navigate to "Space Tools > Advanced Space Functionality > Inherit Restrictions for Pages" and you can select which pages and spaces you would like to have child pages inherit root parent permissions.

The documentation for this feature is available from here.

I hope this helps!


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,852 views 27 11
Join discussion

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