Page tree
Skip to end of metadata
Go to start of metadata

 

JIRA has this annoying habit of adding commas to Number custom fields:

Sometimes a comma is appropriate, but sometimes it isn't. There is a feature request to make commas optional ( JRASERVER-7582 - Getting issue details... STATUS ), but the limitation is baked deep into the custom field system, and since the request has been open since 2005, I'm not holding my breath.

Possible alternative: use a Text field

A workaround is to use a Text field (single line) instead, but then:

  • there is no input validation to ensure what's entered is a number
  • with text fields, you can't do greater-than or less-than comparisons 
  • with text fields, you can't use JQL's equals operator ("Transaction ID" = 10002)

    (see  JRASERVER-21372 - Getting issue details... STATUS )

  • with text fields, you can't use JQL's IN operator ("Transaction ID" IN (10002, 10003)):

There are workarounds for the problems with this workaround: input validation can be achieved with a post-function validator. The last two problems can be fixed by install a plugin – Stattable Searchers or Natural Searchers.

Hacking JIRA

The final solution (for non-Cloud) is to tweak JIRA's Number field velocity template. Specifically:

  1. find the ID of the Number custom field you'd like to de-comma. The ID can be seen in the URL when editing or configuring the custom field in the administration section. For this example we use ID 16300.
  2. edit atlassian-jira/WEB-INF/classes/templates/plugins/fields/view/view-number.vm
  3. Replace the line:

        $!numberTool.format($value)

    with lines:

    #if($customField.id == 'customfield_16300')
    $value.longValue()
    #else
    $!numberTool.format($value)
    #end
  4. Restart JIRA. 

This is what Atlassian's KB article suggests, except that here we do it for one field only. Also, the KB article's suggestion to make velocity templates editable by editing velocity.properties no longer works.

Note that the hack will need to be ported forward every time you upgrade JIRA.

  • No labels