Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner and Code Block Macro - bodyAsString does not work

I'm writing a ScriptRunner snippet to pull content from a page so that I can parse it, and so far I've been able to pull content but it ignores the content in the code block macro, is there something I'm missing, or will this method not work with content in macro blocks?

 

import com.atlassian.sal.api.component.ComponentLocator

import com.atlassian.confluence.pages.PageManager

import com.atlassian.confluence.pages.Page

 

def pageManager = ComponentLocator.getComponent(PageManager)

def page = pageManager.getPage(myPageID)

return page.bodyAsString

 

Is there a mistake in that, or another way to pull the content in the page other than page.bodyAsString?

1 answer

0 votes

I don't see a mistake with this.

Here is what I see when i do the same:

  • This is the target page:2019-10-18 13_12_35-Test page2 - Peter-Dave Sheehan - Confluence - QAD Inc - http___qgorqadlin541.qa.png
  • This is the macro preview:2019-10-18 13_15_47-Edit - Home - Peter-Dave Sheehan - Confluence - QAD Inc - http___qgorqadlin541.q.png
  • When you look a the code behind the preview (chrome developer panel):2019-10-18 13_16_20-DevTools - qgorqadlin541.qad.com_8080_pages_editpage.action_pageId=35241928.png

So in my case I need to be able to return the information in the code block, and when I try it just skips over.  Using your example I need it to return:

A page with

content inside code block

Content after

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

462 views 24 9
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you