Confluence table transformer - Access href and text properties of link to rename hyperlink
Asked by Jannis Louw:

I'm using Confluence table transformer. I would like to rename an existing hyperlink as part of a query. Is there a way to access href and text properties of an existing link to rename the hyperlink? I need this in order to build a new FormatWiki based hyperlink with the updated text title.


Answers:
author: Katerina Kovriga {Stiltsoft}
body: Hi [@Jannis Louw](/t5/user/viewprofilepage/user-id/4468977) ,

I'm not sure if I've gotten your case right but here is the option that I can suggest (if it doesn't suit you please clarify the question and attach some screenshots).

So here is your page in the edit mode:

![Thu 12-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/152445i40EF22A7EC4962B7/image-size/large?v=v2&px=999 "Thu 12-1.png")

The first column contains raw links that you manually paste for your wiki page. The second column provides description for your links.

The links in the first column can be often changed and it's not convenient to rename them manually. And, of course, raw links look not so appealing.

If this is the case, you may try the following SQL query:

SELECT  
FORMATWIKI("\[Click here\|" + T1.'Regular link' + "\]")  
AS 'Check the required info',  
T1.'Description'  
FROM T1

![Thu 12-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/152447iE0DC51A006D1307E/image-size/large?v=v2&px=999 "Thu 12-2.png")

![Thu 12-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/152448iB85E1B6708DCDEBD/image-size/large?v=v2&px=999 "Thu 12-3.png")

Here we renamed all the raw links from the first column and hid the original raw view.

And if you need to **construct (build) links from** **multiple text pieces** put together (where the one changing piece comes from a table column) please follow [this example](https://docs.stiltsoft.com/display/public/TFAC/Advanced+table+cells+formatting#Advancedtablecellsformatting-Creatingclickablelinks).


author: Jannis Louw
body: This will get you the text and link properties of a hyperlink where header is Link:

SELECT \*,  
FORMATWIKI( "\[" + T1.'Link'-\>tfView-\>match("href=(\[\^ \>\]\*)")-\>1-\>slice(1, -1) + "\|" +  
T1.'Link'-\>tfView-\>match("href=(\[\^ \>\]\*)")-\>1-\>slice(1, -1) + "\]" ) AS 'New Link',  
T1.'Link'-\>tfView-\>match("\[\^\>\]+\>(\[\^\<\]+)")-\>1 AS 'Text'  
FROM T\*


author: Jannis Louw
body: ![Confluence_link.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/152468iAC6BBB0D19DD59E7/image-size/large?v=v2&px=999 "Confluence_link.PNG")Hi [@Katerina Kovriga {Stiltsoft}](/t5/user/viewprofilepage/user-id/1464746)

This is very useful - thanks. My problem is however slightly different in that my table has links similar to the "Click here" link in your last screenshot - the link text is "Click Here" and does not contain the full address although clicking on the URL will take me to the desired location (as the address is set). I want to rename the "Click here" link text to something else without losing the hyperlink (link address).

In order to do so using FormatWiki I need a way to access the Address property of "Click Here".

Is there any way to do that?

Thanks, Jannis

comments: author: Katerina Kovriga {Stiltsoft}
body: Hi [@Jannis Louw](/t5/user/viewprofilepage/user-id/4468977) ,

I've consulted with our developers and got a more complex SQL query that may suit your case:

![Fri 4-1.png](https://community.atlassian.com/t5/image/serverpage/image-id/152583iCD2D31C71EE1E742/image-size/large?v=v2&px=999 "Fri 4-1.png")

![Fri 4-2.png](https://community.atlassian.com/t5/image/serverpage/image-id/152584i8C68D12C86346E1D/image-size/large?v=v2&px=999 "Fri 4-2.png")

SELECT \*,  
FORMATWIKI( "\[Bla-bla link\|" +  
T1.'Link'-\>tfView-\>match("href=(\[\^ \>\]\*)")-\>1-\>slice(1, -1) + "\]" ) AS 'New Link'  
FROM T\*

![Fri 4-3.png](https://community.atlassian.com/t5/image/serverpage/image-id/152585i426C8A6BB7D8FB38/image-size/large?v=v2&px=999 "Fri 4-3.png")

Now the Link and the New Link columns mirror each other and contain the same corresponding links (and you may hide the Link column, of course).


author: Jannis Louw
body: This works perfectly, thank you so much!


Tags: confluence-server

server