Forums

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

How do I extract text or link from a custom smart value?

Vin July 31, 2021

I'm able to extract the "Review link" field as a Smart Value with `{{issue.Review links}}`

But in Slack, it ends up like this:

[https://docs.google.com/document/d/BLAH%7Chttps://docs.google.com/document/d/BLAH%7Csmart-link]

 

How can I get it to display like this?

https://docs.google.com/document/d/BLAH

or ideally this:

Review link 

 

EDIT:

1. My easier ask is just to remove the surrounding square brackets, so that I can just work with the double-link directly.

2. The most ideal solution would be to extract the pure link (ie. everything from "https" until, and not including "%7" but this might be too much to ask.

So 1, would allow me to at least format it how I'd like even with a longer link than necessary.

4 answers

1 accepted

1 vote
Answer accepted
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 2, 2021

Hi @Vin ,

Automation offers a variety of functions for working with text strings. In your case, you could use a substring function:

{{issue.Review link.substringBetween("[","%")}}

 which in your example, would return 

https://docs.google.com/document/d/BLAH

 

I think the other options provided as answers would generally work with URL custom fields in Jira. The link encoding you see (square brackets, the pipe "|" character represented as %7C) might be the result of using a text custom field type that allows a lot of text, and Jira is encoding the links when storing the text field. Can you, for example, save multiple links in your Review Links field, separated by normal text? Or you could double-check the field type from Jira's Custom Field administration screen.

Cheers,
Daniel | Atlassian Support

Vin August 2, 2021

Hi Dan,

The field type is for the Review link field is` Wiki Style Renderer ` and yes, multiple links can be stored.

The substring example you provided works for multiple links. For a single link, I had to modify it to `{{issue.Review link.substringBetween("[","]")}}` for a story with a single review link.

Would there be a better solution that's designed for the Wiki style renderer that would allow extraction of single and multiple links?

Thanks,

Vineeth

Kirill Kamenkov August 2, 2021

Try ignoring the rendering by adding .text, and then format the text the way you want to see it in Slack.

{{issue.Review link.text}}
Like Daniel Eads likes this
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 3, 2021

Thanks for the extra field context - I think that's what's been missing. Most answers have approached this from the perspective of not using the wiki renderer (instead using the default renderer).

Kirill's answer is right - the .text function will strip out the link formatting and show only what would have been rendered as the link. From your example where the link text is the same as the link, this should work. Where this would not work is if you had custom link text like this:

[your custom link text|https://example.com]

You could avoid this being a problem going forward by switching the field to the default renderer, as it will correctly handle links and not present them to Automation as wiki markup. Switching it would expose all the previously-saved values of that field as wiki markup however - you'd probably want to go back and update all the fields if you changed the renderer.

Like Vin likes this
Vin August 25, 2021

Thank you - this has been very helpful!

1 vote
Alex Koxaras -Relational-
Community Champion
August 1, 2021

Hi @Vin

I tried to send a slack message via Jira Automation and worked fine on me. For testing purposes I've used the manual trigger. When sending the message to slack, I've surrounded the smart value between <>. Try the latter.

myrule01.png

Let me know if that works.
Alex

Alex Koxaras -Relational-
Community Champion
August 2, 2021

@Vin

Doing what I've told you, you will end up with the following result (without any brackets):

link.png

This isn't what you are looking for?

Like Vin likes this
0 votes
Kirill Kamenkov August 2, 2021

Check the documentation:
https://api.slack.com/reference/surfaces/formatting#linking-urls
I think you need something like that:

<Review link|{{issue.Review link}}>
Vin August 2, 2021

That simply outputs `<>`

Vin August 2, 2021

The issue with formatting in Slack is fine. The question is more about how to extract the link from Jira out of the brackets : [www.google.com], and preferably remove the HTML formatting too.

0 votes
Alexander Pappert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 1, 2021

I can't open your links

can you try {{issue.Review links.Name}} or something like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events