The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

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

Jayson Kurtyka
September 23, 2022

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

4 votes
Answer accepted
Bill Sheboy
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 Champions.
September 23, 2022

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

Jayson Kurtyka
September 24, 2022

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
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events