How to generate macro id Edited


Im working on a script listener that need to auto create a page with unknown number of MultiExerpts Include macros (the listener runs aftar 'lable added' and reads the data from the page related to the event - contains excerpts).

Im having a problem to create the new macros and my assumption is that i need to generate macro id for each.

Waiting for your advise 

  for(def m=0; m < MultiExcerptNames.size(); m++){
def Temp = '<p><ac:structured-macro ac:name="multiexcerpt-include" ac:schema-version="1" ac:macro-id="2d136aa1-2a89-4d59-a9d3-407d20467b21"><ac:parameter ac:name="MultiExcerptName">pub_domain_model</ac:parameter><ac:parameter ac:name="PageWithExcerpt"><ac:link><ri:page ri:space-key="TM" ri:content-title="test" /></ac:link></ac:parameter></ac:structured-macro></p></ac:layout-cell><ac:layout-cell><p><br /></p></ac:layout-cell></ac:layout-section></ac:layout>'
Temp = Temp.replace('ri:content-title="test"', 'ri:content-title="'+MicroServicePage.title.toString()+'"')
Temp = Temp.replace('2d136aa1-2a89-4d59-a9d3-407d20467b21',(MacroId) new MacroId)
Temp = Temp.replace('ac:name="MultiExcerptName">pub_domain_model</ac:parameter>', 'ac:name="MultiExcerptName">'+MultiExcerptNames[m].toString()+'</ac:parameter>')
Temp = Temp.replace('ri:space-key="TM"', 'ri:space-key="'+MicroServiceSpace+'"')
TechPubPageContent = TechPubPageContent + Temp.toString()

def TechPubPage = new Page(title: MicroServicePage.title , bodyAsString: TechPubPageContent ,space: TechPubSpace , parentPage: parentPage)
pageManager.saveContentEntity(TechPubPage, DefaultSaveContext.DEFAULT)
pageManager.saveContentEntity(TechPubPage, DefaultSaveContext.MINOR_EDIT)


1 answer

ignore this comment

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted 3 hours ago in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

25 views 0 2
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you