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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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 _Adaptavist_ 

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

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

Hi @Ravi Sagar _Adaptavist_ 

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

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
Community showcase
Published in Marketplace Apps & Integrations

Learn how to request and manage app requests in the Marketplace

G’day everyone! Super exciting news coming from the Marketplace. We have now fully rolled out the ability for end-users to submit app requests to admins directly from within the product! No longer ...

62 views 1 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you