Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,064
Community Members
 
Community Events
168
Community Groups

How to use Smart Values to get comment body of comment that contains specific data

Hello all.  I've been this for awhile with no luck so trying here:
I have a link for Confluence document (it is only the text, not hyperlinked as I learned that will cause other issues for what I am doing) in a comment for a Task and I want to be able to go through all the comments for this Task, whether there is only 1 or there may be 10, for that Task with smart values to find the comment with the link text and grab that link text only.  This is no doubt a long way around but I am unfamiliar with how to tie complex searches together using smart values.

Here is what I have so far and I believe what is happening is that this statement searches all the comments for the substringBefore and since there are multiple comments and all but 1 has the https that I am searching for all the comment info is taken into account and so no data is returned.  How would I modify this statement to return only the comment body that has the https link it (meets the substringBefore(":"), "https"?

{{#if(equals(issue.comments.body.substringBefore(":"), "https"))}} {{issue.comments.body}} {{/}}

 

1 answer

1 accepted

3 votes
Answer accepted

Hi @Jayson Kurtyka -- Welcome to the Atlassian Community!

Please take a look at this article on smart value, list filtering to help with that: https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

For example to do what you ask, iterate over the comments and check the body in the condition:

{{#issue.comments}}{{#if(exists(body.match(".*(https:).*")))}}{{body}}{{/}}{{/}}

This one uses match() to find the URL, and then when found returns the comment body.  If you expect more than one result, you can adjust this accordingly, such as with a delimiter between comment bodies.

Kind regards,
Bill

Hi Bill!  Thank you for the welcome and I'm glad to be here!  Thank you for looking into this.  I was thinking of the iteration but just didn't know the syntax for laying it out but will take your reply and example and work with it and let you know how it goes.  Thanks again!!

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events