Forums

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

How do i enforce 2 decimal places in a number field?

Scott Federman February 8, 2022

I have a number field (Cap) im looking at automation to enforce that this number field always has only two decimal places. Right now the default is 3. So in short i am looking for the three following scenarios

Cap: 25.536 becomes 2.54

Cap: 25 becomes 25.00

Cap: 25.2 becomes 25.20

Ive tried using the following smart value {{issue.Cap.format("###.##")}} when "Cap" field is changed, but am not having any luck.

2 answers

0 votes
Nithaya
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 14, 2022

Hi @Scott Federman ,

 

I'm Nithaya from the Automation team here at Atlassian. Did you manage to find a solution? I tested out ROUND suggested by @Mark Segall and it seams to work. 

In your screenshot, it looks like you missed the second parameter:

{{#=}}ROUND({{issue.Cap}},2){{/}}

 Did you try again with the second parameter?

 

Cheers,

0 votes
Mark Segall
Community Champion
February 8, 2022

Hi @Scott Federman - You probably want to use ROUND

{{#=}}ROUND({{issue.Cap}},2){{/}}

 Not sure if the preceding/closing is required, but that's a copy/paste of what I've used in the past.

Scott Federman February 8, 2022

Hey @Mark Segall thanks again for your help. Unfortunately, that one didn't work:( I looked at the log and it says no change. 

Mark Segall
Community Champion
February 8, 2022

Can you share a screenshot of the rule so I can get a better sense of what you're trying to accomplish?

Scott Federman February 8, 2022

@Mark Segall  of course!automation.JPG

Mark Segall
Community Champion
February 8, 2022

You got me stumped on this one.  Hopefully someone else in the community has a fresh perspective.

Pradeep Cheekurthi March 1, 2023

Hi, 

Here is the solution I have found to limit the decimal places. I have tried and it worked fine.

Screenshot 2023-03-01.png

We need to use the below smart values

"{{issue.<field name>.format(".#")}} - For upto 1 decimal place

{{issue.<field name>.format(".##")}} - For upto 2 decimal places

{{issue.<field name>.format(".###")}} - For upto 3 decimal places"

 

Thanks,

Pradeep

Neeta Dubey
Contributor
June 3, 2024

This works! Thank you.

Suggest an answer

Log in or Sign up to answer