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
Community showcase
Posted Oct 11, 2018 in Confluence

What are your project planning tips?

Hello Community,  Jessica here from the Confluence product marketing team! Today I wanted to get your takes on project planning –– what works, what doesn’t, how do you know if you’re doing it r...

319 views 1 4
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