Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Extract text from a comment to use in a field

David Fawkes January 10, 2023

Hi i would like some advice on how to extract specific part of text from a comment. I am looking to extract a part of line so i can then paste this into a custom field. 

 

Any advice?

1 answer

1 accepted

3 votes
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 10, 2023

Hi @David Fawkes,

Welcome to Atlassian Community!

You can do that with smart values and automation. The smart values for text fields have lots of options to extract substrings from a field. For example I am using this in one of our automations to find Prisma Alert Ids:

{{issue.description.substringBetween("This was Prisma Alert ",",")}}

David Fawkes January 11, 2023

 

Thanks for this suggestion but i cannot get it to pick up the field from the comments. 

The text comes in via a comment as below and i want to take the U439090 section and put this in to a field in Jira. The number though will always be different.

 

..............................

Work Order No: U439090

Origination Date: 06/01/2023

Originator: eng-341

Asset Number: IZC12

Priority: D

David Fawkes January 11, 2023

@Mikael Sandberg thanks see the note above do you have any other suggestions? 

 

Thanks

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 11, 2023

So something like this should do it for you assuming that it is the last comment:

{{issue.comments.last.body.substringBetween("Work Order No: ", "Origination")}}

Morgan Watts
Contributor
January 4, 2024 edited

Thanks for this. Had a similar request come in and this was an awesome answer. @Mikael Sandberg 

Like Mikael Sandberg likes this
Tschilar, Stacey April 30, 2024

I have a question on this - I can't seem to get the automation to work if my before string contains a colon? 

{{issue.description.substringBetween("Benefit Analysis","Acceptance Criteria")}}

The above works fine, but my issue description is usually in the form of Benefit Analysis: abcdef etc.

So I edited to {{issue.description.substringBetween("Benefit Analysis: ","Acceptance Criteria")}}

and now the automation doesn't return any text. Why is that? 

Morgan Watts
Contributor
May 3, 2024

@Tschilar, Stacey Not that this comment solves the problem, but my string looks like yours when handling text with a colon. I'm parsing the last comment for onboarding information. 

{{issue.comments.last.body.substringBetween("Position/Title: ", "Department")}}

Maybe the ".body." portion of the smart value could make your automation work?

Tschilar, Stacey May 6, 2024

Hmm, I tried this but am still getting blanks: 

{{issue.description.body.substringBetween("Benefit Analysis: ", "Acceptance Criteria")}}

Morgan Watts
Contributor
May 7, 2024

Rats :/ 

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 7, 2024

@Tschilar, Stacey It should work even if the text contains colon, I have a parser that convert an email from Workday to extract data from it and it has colons in it. Does you comment that you are parsing by any chance contain white spaces/new lines in the part that you are trying to parse? And what are you doing with the parsed text? Are you trying to set a select list field with it?

Suggest an answer

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

Upcoming Jira Service Management Events