Just updated ScriptRunner to 4.3.15 now Custom Fields not Available?

KEITH TYSON December 18, 2016

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

0 votes
Answer accepted
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2016

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

 

KEITH TYSON December 19, 2016

Hi Thanos,

This has done the trick perfectly.

Thank you very much for your help on this.

Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2016

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   

0 votes
KEITH TYSON December 19, 2016

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

0 votes
Thanos Batagiannis _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2016

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

Suggest an answer

Log in or Sign up to answer