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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,558,992
Community Members
 
Community Events
184
Community Groups

Usage of "Send custom email" postfunction of scriptrunner in workflow

Hi there,

I'm quite new to Scriptrunner und just getting started. I want to use the "Send custom email" workflow postfunction of scriptrunner. Everything is almost fine but there remain two problems:

I'm using this body template:

<ul>
<li><b>Summary:</b> ${issue.summary} </li> <br>
<li><b>Issuekey:</b> ${issue.key}</li> <br>
<li><b>Priority:</b> ${issue.priority} </li> <br>
<li><b>Reporter:</b> ${issue.reporter} </li> <br>
<li><b>Created Date:</b> ${issue.created} </li> <br>
<li><b>Description:</b> ${issue.description} </li> <br>
<li><dl>
<dt><b>All Comments:</b></dt>
<br> XXX
</dl> </li> <br>
<li><b>Text123</b> <br> longer text sentence[...]
</li>
</ul>

1) The ouput of "priority" does not work. Neither in the preview nor in a real testmail. There always occurs:

Priority: IssueConstantImpl[[GenericEntity:Priority][sequence,4]statusColor,#EF612C[name,Very High][iconurl,/images/icons/priorities/major.svg][description,][id,10200]]

What am I doing wrong here? I just cannot figure out what is causing this?!

2) I need to include all comments of the issue (incl. a comment added during the transition of the triggering post function). Previously I've used the jmwe email issue postfunction, but it was limited as I need to change the real From-Sender-Address --> therefore I switched to the scriptrunner postfunction.

In the jmwe postfunction I used this code successfully (provided by the jmwe community leader) to catch all comments:

<%= issue.get("comment").collect{"<dd><li>"+it.bodyHtml+"</li></dd>"}.join('\n') %>

This does not work anymore in the template mentioned above.

How can I achieve in the scriptrunner postfunction to include all comments (at position XXX) of the affected issue in the template?

Thank you all very much for your help in advance.

Best regards
Mario

1 answer

1 accepted

1 vote
Answer accepted
Ravi Sagar _Sparxsys_
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.
Jun 15, 2020

Hi @Mario 

1. Try this for priority.

${issue.priority.name}

2. For last comment try this.

${com.atlassian.jira.component.ComponentAccessor.getCommentManager().getLastComment(issue).body}

For  all comments try this.

${com.atlassian.jira.component.ComponentAccessor.getCommentManager().getComments(issue).collect{it.body}.join('\n')}

I hope it helps.

Ravi

Hi @Ravi Sagar _Sparxsys_ 

thank you for the fast answer. 

1. is working as expected. ;-) 

2.

${com.atlassian.jira.component.ComponentAccessor.getCommentManager().getComments(issue).collect{it.body}.join('\n')}

--> This does correctly provide all comments, but only as a single line:

13245 1324 blibla   1 bitte prüfen   alles ok done dfghjkl test test2 [^1234.txt] [^test.xlsx] test3 mit attachments test 4 + bes-support in to 123 first test scriptrunner built in mail custom

Do you see any chance how I can get all comments listed up one below each other? Best would be to have any kind of indicator when a comment ends and the next comment begins, e.g. that the comment has a "key point" indicator like "-" or s.th. similar?!

Thank you very much!

Best regards

Mario

Ravi Sagar _Sparxsys_
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.
Jun 16, 2020

Try with <br>. You can also enclose this with <li> to have them displayed as a list.

Hi @Ravi Sagar _Sparxsys_ 

thank you once again.

Sorry for the dumb question but where exactly within the code 

${com.atlassian.jira.component.ComponentAccessor.getCommentManager().getComments(issue).collect{it.body}.join('\n')}

should I place "<br>" or "<li>[...]</li>?

No matter where I've tried it the preview always fails?!

Best regards

Mario

Ravi Sagar _Sparxsys_
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.
Jun 18, 2020

Hi @Mario 

Try this.

<ul>
${com.atlassian.jira.component.ComponentAccessor.getCommentManager().getComments(issue).collect{ '<li>'+it.body+'</li>'}.join('<br>')}
</ul>

Make sure the email format is HTML.

I hope it helps.

Ravi

Works like a charm, thx a lot.

Here the complete code I'm using, if anybody needs it later on:

 

<% def commentManager = com.atlassian.jira.component.ComponentAccessor.getCommentManager() %>
<% def comments = commentManager.getComments(issue) %>

<ul>
<li><b>Summary:</b> ${issue.summary} </li> <br>
<li><b>Issuekey:</b> ${issue.key}</li> <br>
<li><b>Priority:</b> ${issue.priority.name}</li> <br>
<li><b>Reporter:</b> ${issue.reporter} </li> <br>
<li><b>Created Date:</b> ${issue.created} </li> <br>
<li><b>Description:</b> ${issue.description} </li> <br>
<li><b>All Comments:</b>
<ul>${com.atlassian.jira.component.ComponentAccessor.getCommentManager().getComments(issue).collect{ '<li>'+it.body+'</li>'}.join('<br>')}
</ul>
</li> <br>
<li><b>Information:</b><br>Text[...]
</li>
</ul>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events