Forums

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

Is there a way to get a portion of a comment on Jira?

Danisse
Contributor
April 4, 2023

I'm trying to automate a way to copy the latest comment to a custom field. While it is working only want to get the last portion of the comment.

1 answer

1 accepted

3 votes
Answer accepted
Sam Nadarajan
Community Champion
April 4, 2023

Hello @Danisse 

It sounds like smart values may be the solution here. Here's a link to some of the text expressions available for use in smart values. I think you may find the right and substring functions to be the best use case for you.

In terms of grabbing the last portion of the most recent comment, you'll probably end up having a smart value that looks similar to this:

{{issue.comments.last.body.substring(7}}

or 

{{issue.comments.last.body.right(50}}
Danisse
Contributor
April 4, 2023

Hi @Sam Nadarajan 

 

My test comment ends with Project Name: Maya and I just want to retrieve the Maya part. 

 

Attached is the screenshot of my current script

Danisse
Contributor
April 4, 2023

MicrosoftTeams-image (1).png

Sam Nadarajan
Community Champion
April 4, 2023

@Danisse looks pretty close! Can you try 

{{issue.comments.last.body.substringAfterLast(":"}}

You may need to escape the quotes inside the substringAfterLast parameter because you are already inside a quoted string for customfield_13835.

Additionally, you should just be able to plug in this smart value in the field selection above this section, instead of configuring the JSON. 

Danisse
Contributor
April 4, 2023

Hi Sam was able to resolve it :) Thanks much!

Sam Nadarajan
Community Champion
April 4, 2023

No problem! If this answer helped, would you mind accepting it so others that come across it can easily move forward?

Thank you!

Suggest an answer

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

Atlassian Community Events