You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try with <br>. You can also enclose this with <li> to have them displayed as a list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.