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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

How do I get the value of custom field in Send custom email post-function?

Hi,

I configured a "Send custom email" postfunction and it should use on of my custom fields (Text field type) to fill in the subject and body template. I looked at https://community.atlassian.com/t5/Marketplace-Apps-Integrations/How-to-add-a-text-custom-field-value-to-custom-email-script/qaq-p/456714 and https://scriptrunner.adaptavist.com/4.3.6/jira/builtin-scripts.html#_send_a_custom_email but none of this seems to work for me.

This is a subject template I use:

${issue.key} My subject: <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("customField_name")) %> ${cfValues['customField_name'] ?: ""}

This is body template I use:

Custom field value: <% out << issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("customField_name")) %>

${cfValues['customField_name'] ?: ""}

In an email I get:

Subject:

JSD-123 My subject: &lt;% out &lt;&lt; issue.getCustomFieldValue(componentManager.getCustomFieldManager().getCustomFieldObjectByName("customField_name")) %&gt;

Body:

For issue.getCustomFieldValue... I get Java error during Preview although this exactly follows the example in https://scriptrunner.adaptavist.com/4.3.6/jira/builtin-scripts.html#_send_a_custom_email :-(

Using ${cfValues['customField_name'] ?: ""} returns nothing similarly to subject

Any ideas? Documentation seems not to be helpful here or I'm missing something.

regards,

Szymon

1 answer

Hi @Szymon Trocha 

I have checked on my instance, work well.

${getWorkflowButtons.call()}
test
Custom field value: <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("ios dev")) %>

Could You please check name of the custom field?

A.PNG

B.R.

Hi Andriej,

Thank you for help. It works now when I used:

issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Field_name"))

Do you maybe know and can explain why I needed to use ComponentAccessor instead of componentManager and the the full path "com.atlassian.jira.component.ComponentAccessor" ?

Regards,

Szymon

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Asked in Jira Service Desk

Calling all Insight users, we need your help!

Hello Insight users,  As part of our (Mindville's) acquisition by Atlassian, our training team is looking to build some new Insight training materials. It would really helpful if you can ...

231 views 3 5
View question

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