Forums

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

Remove the .0 from numbers when coping them to another field.

Lara Lopez
Contributor
August 13, 2021

Hello,

I have a number field that I need to be copied to a text field. I use Automation fro Jira for this.

Jira always adds a .0 when I use {{issue.customfield_0000}}.

I have tried

{{issue.customfield_00000.remove((.0))}} 

{{issue.customfield_00000.replaceAll("([0-9])"."")}}

And none of them work,

{{issue.customfield_00000.remove((.0))}} works if it is from text field to text field.

Any idea of the correct syntax?

Thanks

 

3 answers

2 accepted

1 vote
Answer accepted
Nic Brough -Adaptavist-
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 13, 2021

If the fields are numeric, then the problem is not the extract and copy, it's the display format of the field.  There's nothing you can do about that in the automation, you'll need to look at the field display settings.

Lara Lopez
Contributor
August 16, 2021

Hello Nic,

Only the first field is numeric, the second one is a text field. 

Nic Brough -Adaptavist-
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 16, 2021

That would explain it.  You're taking a numeric value which is a number and has nothing to say about how it is displayed and converting it to a string and the conversion code is assuming that because a number could be fractional, it's putting a .x on the end to show that.

issue.customfield_00000.replaceAll("([0-9])"."")

doesn't do anything because the source custom field does not have a .0 in it - it's a number, not a string.  You need to do the replacement *after* converting to a string.

0 votes
Answer accepted
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.
August 13, 2021
Lara Lopez
Contributor
August 16, 2021

ac.png

Thanks Bill, but none of them worked :(.

BR

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.
August 16, 2021

Interesting... I rechecked and all of those functions work as documented for me.  Please note that for format() you need to provide a format string, such as .format("#")

And, I noted you are using Server version, so let's try this syntax:

{{#=}}FLOOR({{issue.customfield_18986}}){{/}}
Like Raegen Greene likes this
Javier Boluda
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 3, 2023

I've found a similar problem.

In my case, copying a numeric field into a text field, adds extra position by the right, showing E11 value (which was eleven zeros)

Using Floor conversion caused the same extra position by the right.

I share the syntax has fixed the problem and has worked in my case:

{{issue.customfield_18986.format("###") }}
Like # people like this
0 votes
Vinod Kotiya
Contributor
January 17, 2025

Simply run an automation and edit the field with {{issue.fieldname.replace(".0","")}}

Suggest an answer

Log in or Sign up to answer