Getting value of a custom field into custom email template

I have created a Post Function which sends a custom email on transition of a workflow state. The email format is of type HTML and hence am sending the details using HTML tags.

If I want to include the system fields I use - <td>${}</td> and the value of Priority fields gets fetched and displayed into my email template. But when I use the same(for eg., <td>${issue.priority.tool}</td> as tool is a custom field) to get the value of a custom field it doesn't work.

I referred - and tried - <td>${issue.getCustomFieldValue("customfield_10401")}</td> I get the following error -

ERROR [workflow.ScriptWorkflowFunction]: Script function failed on issue: TEST-117, 
actionId: 11, file: null
No signature of method: com.atlassian.jira.issue.IssueImpl.getCustomFieldValue() 
is applicable for argument types: (java.lang.String) values: [customfield_10401]
Possible solutions: getCustomFieldValue(com.atlassian.jira.issue.fields.CustomField), 
setCustomFieldValue(com.atlassian.jira.issue.fields.CustomField, java.lang.Object)


Please help. Thanks.


1 answer

1 accepted

1 vote
Accepted answer

Hi Arpan,

try in the email body

def cf = com.atlassian.jira.component.ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("TextFieldA")
def cfValue = issue.getCustomFieldValue(cf)

Also which version of ScriptRunner you use ?

regards, Thanos

Wonderful. This works. I am really not sure which version I am using. I am new to this. I am just using web based editor to edit the email templates using HTML format. Also, can you help in - how I can find previous workflow state and provide it into an email template? I just want to tell user that the workflow state has been changed from-to.


transientVars is available to you, so you can get that information using

Rather than writing in the template you can inject in some extra variables:


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,664 views 18 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you