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
Published Dec 18, 2018 in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

475 views 3 18
Read article

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