Bulk Creation Of Pages From A Template
Asked by Dave Keating:

Hi there! This has been asked a few different ways but I can't find a specific example of what I'm trying to achieve.

I'm looking to manage a HR process within Confluence pages (all contained within a single space).  

To do this, I need to create \~220 individual pages (from a Template) with employee names added into the titles.  

As part of this, I need to manage permissions on the page, only granting access to the employee, manager and exec for each business line.  

The outcome would be a page for each employee in this process, with restricted access to the three relevant people (those people would be different for each page created).  

I'm looking for a way to automate this process, rather than manually creating all the pages. Does anyone know of a solution for this?  

Thank you for any help you can give me!


Answers:
author: Roland Holban (Adaptavist)
body: Hello [@Dave Keating](/t5/user/viewprofilepage/user-id/3922693). You could accomplish what you want using ScriptRunner for Confluence. It should be possible to fully automate this.

You would need to write an inital custom script which you would run in ScriptRunner's Script Console. This will take care of your current users and create pages for them.

Then after, if you want to automate future creation of pages, you could write an Event Listener that would get triggered every time a new user is created and create a page for them.

comments: author: Jonny Carter
body: To say a bit more, we have an example in our documentation on how to create a page whenever a new user is created:

<https://scriptrunner.adaptavist.com/latest/confluence/listeners.html#_create_page_when_user_created>

You could adapt that script to perform the "loop through all existing users and create a page" script that Roland mentioned, above. We have an example of another script that loops through all Confluence users to deactivate inactive ones, which may be helpful. <https://library.adaptavist.com/entity/deactivate-inactive-users-in-confluence>


author: Dave Keating
body: Thank you for this answer! I'm waiting to onboard all users to I can create the page and set the permissions in one hit. Will reply back with process and results once I have done it. Thank you again!


author: Michael Kuhl _Appfire_
body: Hi [@Dave Keating](/t5/user/viewprofilepage/user-id/3922693) as [@Ste Wright](/t5/user/viewprofilepage/user-id/1166470) mentioned you can use the [Bob Swift Confluence Command Line Interface](https://marketplace.atlassian.com/apps/284/confluence-command-line-interface-cli?hosting=cloud&tab=overview) to do this without scripting.

Briefly - assuming you have the list of employees in a CSV file named "employees.csv" with employee, manager and exec columns for each business line and the template page is somewhere on the same Confluence instance you can do something like this:

**Create pages from template:**

Using [runFromCsv](https://bobswift.atlassian.net/wiki/spaces/CSOAP/pages/1061017050/runFromCsv) \| [copyPage](https://bobswift.atlassian.net/wiki/spaces/CSOAP/pages/1059375249/copyPage)

```
acli --action runFromCSV --file "employees.csv" --common "--action copyPage --space \"TEMPLATE\" --title \"Template Page\" --newSpace \"HR\" --replaceTitle \"@employee@\" "
```

**Set page permissions for employee:**

Using [runFromCsv](https://bobswift.atlassian.net/wiki/spaces/CSOAP/pages/1061017050/runFromCsv) \| [addPermissions](https://bobswift.atlassian.net/wiki/spaces/CSOAP/pages/1059405641/addPermissions)

```
acli --action runFromCSV --file "employees.csv" --common "--action addPermissions --space \"HR\" --title \"@employee\" --permissions \"View\" --userId \"@employee@\" "
```

comments: author: Dave Keating
body: Thank you for this answer! Really helpful.


author: Ste Wright
body: Hi [@Dave Keating](/t5/user/viewprofilepage/user-id/3922693)

I don't know a native way of doing this - you might need to consider an app which can help you drive some automation around page creation \& restrictions.

For example, you could look into:

* [ScriptRunner for Confluence](https://marketplace.atlassian.com/apps/1215215/scriptrunner-for-confluence?hosting=cloud&tab=overview)
* [Confluence Command Line Interface](https://marketplace.atlassian.com/apps/284/confluence-command-line-interface-cli?hosting=cloud&tab=overview)
* [Secure Pages for Confluence](https://marketplace.atlassian.com/apps/1221982/secure-pages-for-confluence?hosting=cloud&tab=overview)

All of these have some levels of automation related to the areas you mentioned! Or you could check-out what else is on offer on the [Marketplace](https://marketplace.atlassian.com/) :)

Ste

comments: author: Dave Keating
body: Thank you for this response, it was really helpful.


Tags: cloud

bulk-edit

confluence-cloud