Just updated ScriptRunner to 4.3.15 now Custom Fields not Available?

I have just updated ScriptRunner.

In Send Custom Email, I was using a custom field (script field) in the "To Issue Fields" field.

However, after updating, it cleared the value of this field so my emails have no to addresses. When I go now to enter the custom field again it gives a dropdown of available custom fields, but the script fields are not listed?

3 answers

1 accepted

Hi Keith,

In your Condition and Configuration section add

import com.atlassian.jira.component.ComponentAccessor

def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Scripted Field")

if (!cf)
    log.debug "Scripted field does not exist"

def recipients = issue.getCustomFieldValue(cf) as String

mail.setTo(recipients)

In order to preview you have to select the Disable validation checkbox because you are setting from/to/cc etc dynamically.

PS. Where variable mail is type of Email

Let me know if this does the trick

regards, Thanos

 

Hi Thanos,

This has done the trick perfectly.

Thank you very much for your help on this.

Cool, anytime Keith. 

I will investigate how "easy" will be to add the scripted fields in the dropdown with the available To Issue fields. But the main reason behind not to include is that with a scripted field we are not sure what kind of value/s will have.

Therefore we also updated the Configuration section in order to increase it's flexibility and make it easier to do more complicating things via scripting.

 Hope that in overall you find the changes better.

regards, Thanos   

Hi Keith,

The fields that are available to select from are those that are quite possible to hold valid email addresses or users (and therefore possible to get their email), aka the fields that their type is instance of UserCFType, MultiUserCFType, MultiGroupCFType or TextFields.The scripted field is not in the available fields.

But you can add recipients from the Condition and Configuration section using

mail.setTo(String emailAddress)

If you want to tell me what type of template you use for your scripted field I can assist further.

regards, Thanos

Hi Thanos,

Thank you. I am using Send Custom Email in the workflow Post Functions. I am doing all the formatting (template) in the Email Template section.
I tried to set the email address in the 'Condition and Configuration' section using something like the example you gave ( mail.setTo("abc@xyz.com") ) but it still gives "You must provide either fields or addresses to send emails to."

I have a custom field (script field - below) that stores a comma separated list of email recipients - which was working 100% with previous versions. If I can somehow still use the email addresses in this field and use mail.setTo, that would be good?

image2016-12-20 8:37:40.png

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,849 views 12 18
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot