How to Scriptrunner send custom email and add group picker (multiple) values?

Hi,

I would like to be able to send the values of the group picker (multiple values) in the Scriptrunner send custom email function.

What I tried is this:

<% out << 
issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("My Group Field"))
 %>

The results is this:

[com.atlassian.crowd.embedded.
impl.ImmutableGroup@c6d9f83e, 
com.atlassian.crowd.embedded.impl.ImmutableGroup@1755060d, 
com.atlassian.crowd.embedded.impl.ImmutableGroup@ba45e50b, 
com.atlassian.crowd.embedded.impl.ImmutableGroup@93dd5824]

 

I already searched the internet and only found this:

https://answers.atlassian.com/questions/318102

But the problem is that it's about the possibility to copy the value to another field and I really don't now how and where I should even put the code. (Tried to put it on a transition with the post-function Script Post function and then Custom script post function but then I get method warnings. I guess this has to do with the fact that the script is for JIRA 6 and I'm running 7)

I also tried this:

def groups = (List<Group>) myIssue.getCustomFieldValue("My Group Field");
for(Group group:groups){
    group.name
}

But that didn't work.

So I tried this:

<% out def groups = (List<Group>) myIssue.getCustomFieldValue("My Group Field");
for(Group group:groups){
    group.name %>

But then the mail doesn't even get send.

I think I have 2 options:

  1. I can solve it in the email template
  2. I can copy the values from the group picker (multiple values) to a text field

Does anybody have a solution?

Thanks in advance.

1 answer

1 accepted

4 votes

You should try:

<% out <<
issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("My Group Field"))*.name
 %>

That should get the names of the groups for you.

The syntax of the Groovy GString templates are a little tricky, they are a bit picky about what you can do in them: http://docs.groovy-lang.org/latest/html/documentation/template-engines.html#_gstringtemplateengine

It works! Thank you so much laugh

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Amir Kazemi
Posted 5 hours ago in Jira

We want to know what Jira Service Desk apps you're using!

Hi Community! My name is Amir and I’m on the Jira Service Desk product marketing team at Atlassian. Our team would love to understand how you’re leveraging our ecosystem for Jira Service Desk. Wha...

23 views 0 4
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you