Forums

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

Remove Commas from Custom field (Number type)

Julian Governale
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 13, 2021

We have a customer # field that is a single line text field (customfield_10637) because some customers are Alpha Numeric where others are just numeric.

In the case of numeric customer #'s we are coping those over to a number type custom field (customfield_10768) .  We are doing this as in some cases Customer A may be entered as 001234567 or 0001234567 in the text field which would require the team to search both scenarios.

When we copy the field over to the number field, this allows all results to be returned with one search.  On the display of the issue though, the number field contains commas which really isn't accurate.  

When i use the .format("######") option, it actually just clears my number field.  When i remove the format option,  it copies the field values but includes the commas.

Is there a way i can remove the commas from the number field so its shows just the accurate customer #?  I have also tried, to first copy with the commas, refetch the data and edit the customfield_10768 a second time and reformat it again but same results of it clearing the field.

Here is my automation rule:

customer#_automationRule.jpg

here are the results when i do not use the format option

commas_customer#.jpg

4 answers

1 vote
bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 13, 2021

Hi,

I don't believe you can remove the commas from the number field.   This is just the way the number custom fields are rendered in Jira.  (Though there may be a locale-related setting somewhere,  but it would be per user).

I would probably go what Bill said, and just use a text field,  but reformat the data to remove the zeros.

{{issue.customfield_33333.asNumber}} might be enough to strip the zeros. 

Or,  you could try  {{issue.customfield_33333.asNumber.format("#######")}}.  The "asNumber" is probably be the missing piece of in your original smart value.

Cheers,
Brydie

Julian Governale
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 14, 2021

Thanks @bmccoy  the asNumber was the trick to get it copy properly with the format, commas are still present but its not clearing my field.  I think the text field is probably the only option for my scenario. 

1 vote
Bill Sheboy
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 13, 2021

Hi @Julian Governale 

Rather than a number field, have you considered using a text field for account number, and remove leading zeroes, when needed...for example with a regular expression?

Best regards,
Bill

Julian Governale
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 14, 2021

Thanks for the reply, the reason for the number field is the automatic stripping of leading zero's.  In some cases we can have up to 10 leading zero's but i can test creating a new text field and using regex to strip them.  Im not sure if its the case where we need a scenario for each amount of leading zero, i.e. one if statement for one leading zero all the way to 10 leading zero's. 

I'll give it a test, but was hoping to format the number field would be ideal in this scenario. 

Like Bill Sheboy likes this
0 votes
Lara Lopez
Contributor
August 13, 2021

Hello Julian,

If it is a number field, it is impossible to remove the comas ( and if you have other languages it puts dots) its just the way the field is formatted.

With automation for Jira I have been coping the number fields to other fields getting rid of the , and . for visualization but I like to keep the number fields because some addons can add them up which is a nice feature.

Best Regards

0 votes
Jessica Golden
Contributor
August 4, 2021

I was having a similar issue. 

Try with only three pound signs instead: 

.format("###")

I just tried it with automation for a project I'm working on and it successfully removed the commas and decimals.

NOW returns:  99999

Before it was blank or with commas and/or decimals.

Julian Governale
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, 2021

Is your custom field a number or text field?  I just gave it a try and returned with the commas but i will look more into it as i was doing a lot of testing so let me get back to my starting point too. 

Jessica Golden
Contributor
August 13, 2021

@Julian Governale It is a number field.  The view on the issue still shows with commas, but automation now inputs the data into other text fields without commas or decimals.

Suggest an answer

Log in or Sign up to answer