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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,464,370
Community Members
 
Community Events
176
Community Groups

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

Deleted user Feb 09, 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 Feb 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!!

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 Feb 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

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 Feb 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

@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

Atlassian Community Events