'Is there a way to send metadata to a confluence document via a script?
I have a task where I make a request to download a confluence page from a page and copy it into another with the same content, but changing it's metadata (for example the title of the page is given via a metadata) and I'd like to do this automatically, my idea of it being: the script gets certain parameters (title, author, etc.) and it puts these into the metadata of the second page. Does anyone have an idea how to do this?
Solution 1:[1]
If using ScripRUnner/Groovy Runner you can use such Groovy code:
def PAGE_ID = 123456
def pageManager = ComponentLocator.getComponent(PageManager.class)
def page = pageManager.getPage(PAGE_ID)
def newPage = new Page()
newPage.setTitle(page.getTitle())
newPage.setBody(page.getBodyAsString())
newPage.setSpace(page.getSpace());
pageManager.saveContentEntity(newPage, null);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrii Maliuta |
