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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

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

JEMH velocity template - get custom field value

I thought this would be simple, but a custom fields value will not display in the template. 

I've attempted:

$issue.getCustomFieldValue('customfield_###)

#set( $test = $customFieldManager.getCustomFieldObject("customfield_###"))
#if($issue.getCustomFieldValue($test))
$stringUtils.leftPad($test.name, $padSize): $issue.getCustomFieldValue($test)
#end

 

with no luck. I've reviewed https://docs.atlassian.com/software/jira/docs/api/8.5.4/ but am still not able to render the custom field value. The custom field itself displays all the project roles of a project, so it's always populated.

2 answers

Hi Raynard,

For custom fields with simple string values, something like this should render:


$issue.getCustomFieldValue('customfield_10200')

or

#set($cf = $customFieldManager.getCustomFieldObject('customfield_10200'))
$cf.getValue($issue)

Please ensure that the custom field ID in your template is correct. Also, if you are using this template in an issue workflow post-function, make sure that the notification post-function is ordered to fire after re-indexing has occurred.

You can break your template down in order to debug it:

#set ($cfId = 'customfield_10200')
#set($cf = $customFieldManager.getCustomFieldObject($cfId))
#if ($cf)
Found custom field $cf.getName()
#set ($cfVal = $cf.getValue($issue))
#if ($cfVal)
It has value: $cfVal
#else
It has no value
#end
#else
No custom field found for ID: $cfId
#end

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Published in Marketplace Apps & Integrations

Bitbucket Smart Commits vs. Genius Commits - What's the difference?

If you already heard about Smart Commits in Bitbucket, know that you just stumbled upon something even better (and smarter!): Genius Commits by Better DevOps Automation for Jira Data Center (+ Server...

130 views 0 2
Read article

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