How to generate macro id Edited

Hi,

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

309 views 11 10
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