Send Custom email post function Property 'cfValues['ASID Number']' not found

Deleted user February 9, 2018

I'm using the Script Runner built in post function for "Send custom email" and it Previews without error when I test it in Script Runner, but when I use it in the actual workflow, I get this error regarding a custom field...

image.png 

I use this field in several places (Condition, Email template, Subject template), and they all pass the "Preview" test. I can't find anything wrong with the way I'm putting this together, but I still get the above error. Is there anything else I can try?

 image.png

2 answers

0 votes
Deleted user February 14, 2018

Hi Thanos!!

I finally have it working!! Between your suggestions and information from the site 
https://jamieechlin.atlassian.net/wiki/spaces/GRV/pages/33030148/Built-In+Scripts#Built-InScripts-Sendacustomemail

...I managed to put the pieces together and generate the desired email, without error, and including all the custom fields I wanted. (Once the problem was solved for the "ASID Number" custom field, it applied to the others). 

Wherever I referenced the custom field(s) in the Email template or Subject template, I had to use this rather lengthy reference in order for it to pass the "Preview" AND show up in the generated email:

<% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("ASID Number"))%> 

 

(Note that the "arrows" and the word "out" are part of the entire expression. I'm just mentioning this in case other members think that is some sort of corruption in the web display).

Thanks so much for all your help!!

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.
February 12, 2018

Hi Chris,

Can you try to put the following script in the Condition and Configuration field

import com.atlassian.jira.component.ComponentAccessor

//get the customfield with name TextFieldA
def textFieldCF = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("TextFieldA")

//get the value of that customfield for the current issue
def textFielValue = issue.getCustomFieldValue(textFieldCF)

//store the value of that custom field in the config map and in position with key cfValue
config.cfValue = textFielValue

//condition should return true
true

And then you can call that value in the Email or Subject template fields, like 

The value of TextField Custom field is ${cfValue}

Give it a try and please let me know if that did the trick. 

Kind regards, 

Thanos

Deleted user February 12, 2018

 

 

Thanks for the quick reply, Thanos! Unfortunately, when I tried to put your suggestion into the Condition field, I got a message "No such property: config for class: Script15". 

Script-Error.png

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.
February 13, 2018

Hi Chris,

Sorry I assumed you were in a more recent version. 

In your case then try in the Subject or Email template something like 

<%
def textFieldCF = com.atlassian.jira.component.ComponentAccessor.customFieldManager.getCustomFieldObjectByName("TextFieldA")
def textFielValue = issue.getCustomFieldValue(textFieldCF)
%>

Value of custom field is $textFielValue

Hopefully this will do the trick.

Regards, 

Thanos

Like 3digits - Desarrollo likes this
Deleted user February 13, 2018

Thanks again, Thanos!! 

The 

def textFieldCF  and def textFielValue portions worked for satisfying the Condition without getting any errors. That helped a lot!

However, no matter how I refer to $textFielValue in the email Subject or Body, I still get "No such property" errors. I've tried curly braces ${textFielValue} and other variations, but I can't seem to avoid the error. 

 

Script-Error2.png

Rahul Savaikar March 17, 2022

@Thanos Batagiannis _Adaptavist_ Could you please suggest how I could display a number without any decimal places?

Currently, I have a field which prints the field value in a single decimal format. I do not want to have any decimal places mentioned, as this particular number field value will never have any decimal places.

 

The following code works, however it prints the value along with the decimal part.

<% def totalsize = issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager()?.getCustomFieldObjectByName("Total Size"))
if (totalsize) {
out << "<p><b>Total Size: </b>" + totalsize +"</p>"
} %>

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events