Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner script to edit hyperlinks

Gaven Ray
Contributor
January 16, 2025

I have a script to edit the text on a page 

 


import com.atlassian.confluence.pages.PageManager import com.atlassian.confluence.spaces.SpaceManager import com.atlassian.sal.api.component.ComponentLocator import com.atlassian.confluence.core.DefaultSaveContext def oldText = '' def newText = '' def targetSpaceId = '' def spaceManager = ComponentLocator.getComponent(SpaceManager) def pageManager = ComponentLocator.getComponent(PageManager) def targetSpace = spaceManager.getSpace(targetSpaceId) def spacePages = pageManager.getPages(targetSpace, true) spacePages.each{page -> def pageBody = page.getBodyAsString() if (pageBody.contains(oldText)){ pageBody = pageBody.replace(oldText, newText) page.setBodyAsString(pageBody) pageManager.saveContentEntity(page, DefaultSaveContext.DEFAULT) log.info("Text replaced in page by Scriptrunner '${page.title}' in space '${targetSpace.name}'") } }

 I would like it to be able to change the background link to a hyperlink on a Confluence page. 

1 answer

1 accepted

6 votes
Answer accepted
Benjamin
Community Champion
January 16, 2025

HI @Gaven Ray ,

 

Found an article that may help you with the problem you are trying to solve by adding html tags in your script.

 

https://community.atlassian.com/t5/Marketplace-Apps-Integrations/Hyperlink-with-scriptrunner/qaq-p/880786

 

Hope this helps.

Gaven Ray
Contributor
January 16, 2025

Thanks I will see if I can make this work with what you sent.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
atlassian, rovo agent workshop, loom ideas director, build rovo agent, hands-on workshop, AI agent building, loom integration, product discovery automation, no-code agents, atlassian learning, extract ideas from video, rovo workshop

[AI Workshop] Let's build a Rovo Agent: Loom

Build a Loom Ideas Director agent to turn feedback videos into Jira ideas. Join our hands-on workshop and automate product discovery — no coding needed!

Register now
AUG Leaders

Atlassian Community Events