Remove Commas for Values held in Number Field Custom Field Type

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

The information on this page relates to customizations in JIRA Applications. Consequently, Atlassian Support cannot guarantee the provision of any support for the steps described on this page as customizations are not covered under Atlassian Support Offerings. Please be aware that this material is provided for your information only and that you use it at your own risk.

Also, please be aware that customizations done by directly modifying files are not included in the upgrade process. These modifications will need to be reapplied manually on the upgraded instance.

Jira adds commas to numeric value stored in Number field, like 1,234. For further reference see JRA-7582 - Getting issue details... STATUS .

If you don't want commas to be added, edit /WEB-INF/classes/templates/plugins/fields/view/view-number.vm. Replace the following line:


$!numberTool.format($value)

with:

$value.longValue()


Make sure to back up the Velocity file before changing it.

Disable commas for a single custom field

It's possible that you would like to disable the commas for a single custom field instead of multiple custom fields in this case, we can add the customField.id value to filter for this custom field specifically.

This will require you to identify the custom field ID by inspecting the URL while editing the custom field.

For example, let's assume that we are editing a custom field called "Phone Number" by going to the page ⚙ > Issues > Custom Fields and clicking on ... > Edit next to the field. If we check the URL of the landing page, we can see "id=XXXXX" at the end of it. The value after id= is the ID of the custom field (10900 in the example of screenshot below):


Using the example of custom field ID shown above, the file /WEB-INF/classes/templates/plugins/fields/view/view-number.vm will need to be edited as follows:

#if ($customField.id == 'customfield_10900' && $value)
$value.longValue()
#elseif ($value)
$!numberTool.format($value)
#end

It's possible add multiple custom fields by adding multiple elseif statements.




Last modified on Jul 2, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.