I am running a scriprunner groovy macro on a confluence page, and I want the Space Key of the Space the page is in.
I simply cant figure out how to get it.
I have tried using com.atlassian.confluence.content.render.xhtml.ConversionContext, but I cant get this instanciated, eg the first handle to something that can lead me to the page, and hence the space...
Hi @Normann P. Nielsen (Netic) ,
Thanks for reaching out to Adaptavist support, this is certainly something we can help with! I've replied to the ticket you created in our queue, but I'll share my response here for anyone who encounters the same problem!
During Custom Macro creation and configuration, if you click on the blue '?' icon of the 'Macro code' box, it'll show available binding variables to this script:
For your specific use case, you can use the context (ConversionContext) variable to get the Page or Space object.
Here's an example:
import com.atlassian.confluence.pages.Page
// Entity can be either Page or Blogpost object def entity = context.getEntity()
// Check if entity is a Page object
if (entity instanceof Page) {
// Page Id def pageId = entity.getId()
// Page Title def title = entity.getTitle() // Get Space Object
def space = entity.getSpace() }
Adaptavist does have an example that uses the entity object:
Please do not hesitate to reach out to us if you have further questions, I hope I have answered your query!
Kind regards,
Olly
Hi @Normann P. Nielsen (Netic)
You may want to contact adaptivist for a faster response if you are paying for the app: https://marketplace.atlassian.com/apps/1215215/scriptrunner-for-confluence?tab=support&hosting=cloud
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alreaydy on it, since no answer here :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.