ScriptRunner: Displaying Usernames as Emails but string is comma spliced

Hey all,

I recently found this script online that I have modified a bit and am using to return email address for users inside a scripted field. The only issue is, the returned string has each individual character separated by a comma and I can't seem to find a way to fix this online.

Screen Shot 2017-06-01 at 4.25.18 PM.pngAdditionally, the script seems to run despite the errors on the side. The script is below.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser

def uxfield = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("UX")
if (uxfield == null)
    return "custom field not found"

StringBuilder result = new StringBuilder();
for(ApplicationUser user: (ArrayList<ApplicationUser>) uxfield.getValue(issue))
    result.append(user.getEmailAddress() + "/")

return result.toString().substring(0, result.toString().length() -1)

1 answer

0 vote
Steven Behnke Community Champion Jun 01, 2017

Happy to help but please, instead of pasting code you found on the web, can you please describe the use-case? Secondly, can you let us know what type you plan to return? We can't see the searcher you set on the field and we can't see the template you configured.

Sure. I am using it to convert usernames from one field to display their email addresses for reporting purposes in the scripted field. The searcher is set for a multi-user picker field.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

294 views 4 9
Read article

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