Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get custom field value in scriptrunner custom email postfunction

Vishal
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.
July 26, 2022

Hello 

I am using scriptrunner postfunction Send a custom email, to send email & in the email body, I need to include some custom field values. I am trying to get the field values with below expression, however, it is not working.

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

Could you please help me with the information, how can I include custom field value in the email please ?

Thanks!

2 answers

1 accepted

1 vote
Answer accepted
Vishal
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.
July 26, 2022

Managed to get the field value myself in the mail body using <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Custom Field Name")) %>

Luis Angel Valencia August 2, 2024

Hi Vishal, I hope you are doing well.

Actually I´m using this  line in my body mail <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("MyFieldName")) %>

I want to set another custom field but in this case of "User Picker" type.

 

Do you know how can I set it?

 

Regards.

 

Vishal
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.
August 5, 2024

Hi @Luis Angel Valencia 

I am not sure if I get your question, so you are trying to fetch the user picker field value in the mail, correct ? If so above should work.

Vishal

Luis Angel Valencia August 5, 2024

Hi @Vishal

 

Yes, for example, I have a "user picker"  custom field  called "Architect" and I want the body of the email say something like this.

 

Hi (Name of the "Architect") 

 

You must approve this ticket (URL ticket)

 

Thank you so much.

Rgards. 

 

Vishal
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.
August 9, 2024

Hi @Luis Angel Valencia 

 

If you are using post function then you need to use : <% out << issue.getCustomFieldValue(com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Architect")) %>

 

If you are using simple jira automation then you need to use : {{customfield_12345.displayName}}

Hope it helps

 

0 votes
Florian Bonniec
Community Champion
July 26, 2022

Hi

 

Not sure if it's the only issue but  getCustomFieldObjectByName("MyField") return a List of field because in some case there is multiple fields with the same name even if it's not a good practice.

Use getCustomFieldObjectByName("MyField")?.first()

 

Or use Field ID getCustomFieldObject("customfield_XXXX")

Suggest an answer

Log in or Sign up to answer