Get the body of a comment after the first line

AldoCauchiSavona February 8, 2023

I need to capture the body of a comment, but not the first line.

Is the a smart value way o do this please?
In Javascript, I would get the position of the line break and get the substring after that character positions.

I tried this and an alteration without the inner smart value {{}}, but not luck. Any help on how I could do this please:

{triggerIssue.comments.last.body.substring({{triggerIssue.comments.last.body.indexOf("\n")}})}}

 

1 answer

0 votes
Andrii Maliuta
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.
February 8, 2023

Hello @AldoCauchiSavona ,

It depends on the Storage format of the comment and how the end of the line is represented.

You can get the body of a comment as HTML (VIEW, STORAGE, ...) and try to get the end of line tag/tags and then parse by it.

AldoCauchiSavona February 8, 2023

Thanks @Andrii Maliuta The comment body is being retreive via a smart value {{issue.comments.last.body}}, I currently use {{issue.comments.last.body.substringBefore("\n")}} to get the contents of the first line. 

I can remove or rplace that line with an empty space, but need to know how to use a smart value as a parameter.

{{triggerIssue.comments.last.body.substring(triggerIssue.comments.last.body.indexOf("\n"))}} and neither {{triggerIssue.comments.last.body.substring({{triggerIssue.comments.last.body.indexOf("\n")}})}} doesn't work.

Like Andrii Maliuta likes this
AldoCauchiSavona February 8, 2023

Hi @Andrii Maliuta the smart values I replied with do not work.

Not sure what part of it I'm doing wrong.

Maybe somebody can spot the problem with how I'm writing the smart value please?

Andrii Maliuta
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.
February 13, 2023

@AldoCauchiSavona  , not sure about smart values in this case, sorry :( I ususally work with VM or thymeleaf / HTML JS templates and do the approach described before. 

AldoCauchiSavona February 15, 2023

@Andrii Maliuta would you have a link so I can reaserch and find out more about the HTML JS templates approach which you use?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events