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

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

Cloud Scriptrunner Post Function Notifies (sends email) but inserts brackets in message string Edited

I have a post function that extracts the components and finds email addresses to send from a list. However even when converting the found components and emails to string using <string>.join(", ") it inserts brackets in the email.

In Script Console the email contains what I expect:

Test notification referencing : service1, service2; email,

However when attached as a post function the same code gives an email containing:

Test notification referencing : [{service1, {service2; email

- with extra brackets and no email addresses

I'm new to groovy so the code could be better. The post function is of the form:

def myField = issue.fields.find { it.key == "components" }
def value = myField.getValue()
String s = value // Have to assign the value to s to make value a String

def toks = s.tokenize(', ')
def componentsFound = []

toks.eachWithIndex{it, i -> if(it.contains("name=")){componentsFound.add(toks[i].replaceAll("name=",""))}}

def components = ['service1':'', 'service2':'']

def owners = []
components.each{ k, v -> if(componentsFound.contains(k)) {owners.add(v)}}

String componentList = componentsFound.join(", ")
String ownerList = owners.join(", ")

String message = "Test notification referencing : "+componentList+"; email "+ownerList

def resp = post("/rest/api/3/issue/${issue.key}/notify")
.header("Content-Type", "application/json")
subject: 'Component Bug Notification',
textBody: message,
htmlBody: message,
to: [
watchers: true,
users: [[
name: '<>'

1 answer

Is there anyone from Atlassian or Adaptavist able to help with the above?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Trello

🏊‍♀️ Atlympic Event: Trello

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

172 views 2 13
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