Hi,
I've managed to append content to an existing page in Confluence by scriptrunner console.
Below a sample of the code I'm using, which I know it's far from being an elegant programming example, :-), but in the end it works, and I'm using to introduce text, tables, etc...
//Libraries
import com.atlassian.confluence.pages.Page
import com.atlassian.confluence.pages.PageManager
import com.atlassian.confluence.spaces.Space
import com.atlassian.confluence.spaces.SpaceManager
import com.atlassian.confluence.pages.Attachment
import com.atlassian.confluence.pages.AttachmentManager
import com.atlassian.sal.api.component.ComponentLocator
import com.atlassian.confluence.core.DefaultSaveContext
//Defining the management objects
def spaceManager = ComponentLocator.getComponent(SpaceManager)
def pageManager = ComponentLocator.getComponent(PageManager)
def attachmentManager = ComponentLocator.getComponent(AttachmentManager)
//Defining the page to update (the page already exists)
def outputPage=pageManager.getPage("~BOERIO", "Output")
//Get the current content of the page
def contentEntityObject = outputPage.getContentEntityObject()
def pageBody=outputPage.getBodyAsString()
// I want to add this text to the page
String appendedText="<p>Hello Confluence Page!</p>"
//Building the string with the new content
String outputPageBody=pageBody+appendedText
//Assigning the new content to the page
contentEntityObject.setBodyAsString(outputPageBody)
//Saving the page
pageManager.saveContentEntity(outputPage, DefaultSaveContext.DEFAULT)
//return outputPageBody
My question is related to the risk to reach a size limit for the string I'm building and assigning as new page content. Will I reach the point where the current page content is no more manageable with a string?
Is there a better approach to follow?
Thanks in advance for any suggestion.
Ciao, Andrea
This cannot possibly work.
A select list holds a single item. Converting the UI to a multi-select just makes the data the UI tries to store in the field totally incompatible with it.
You will need to write an app that can provide your new field type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.