Number field formatting

Rafael Ibanhez March 14, 2023

Why can't I simply format a number field to consistently show numbers with 2 numbers after coma? why is that so hard?

I have tried all kind of formatting options with no luck.

issue.<field_number>.format(".##")

issue.<field_number>.format("###,###.##")

<field_number>.format("###,###.##")

<field_number>.format(".##")

 

I don't want to use script running or any APP it should be a simply and native task. But I'm wrong. Unless someone knows what I'm doing wrong. 

1 answer

1 accepted

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.
March 14, 2023

Hi @Rafael Ibanhez 

You appear to be asking about formatting a number with an automation rule.  Is that correct?

If so, please try this:

{{issue.fieldName.format("0.00")}}

 

Kind regards,
Bill

Rafael Ibanhez March 14, 2023

Hi Bill. 

Using .format("0.00") instead of #.## helps with numbers after coma. Remaining problem is:

If I use .format("0.00") works fine until 999.99 following numbers won't have the thousands division, for example, 1,000,000.00 will show 1000000.00.

If I use the .format("0,000.00") then for numbers like 999 will show 0,999.00

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.
March 14, 2023

If you review that documentation, and the linked Java format reference, you can find how to combine these, such as with this:

{{issue.fieldName.asNumber.format("###,###,###.00")}}

Please adjust for a format as large as your numeric value can range. 

Rafael Ibanhez March 16, 2023

I feel dummy right now. That was the solution all along. Thanks for answering 

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.
March 16, 2023

No worries; some of the documentation is a bit vague, and so requires a bit of experimentation to learn what works (or doesn't).

Danno
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 11, 2023

@Bill Sheboy I am having an issue with formatting as well. I'm trying to format a field as a currency. I found the jira-smart-values-math-expressions page and created an automation to format my custom field as currency on issue creation.

The automation claims success upon running and it seems to format the number but without the Currency type indicator as described by this:

asCurrency

Formats a number as a currency in the US locale. For example, 0.123 becomes $0.12.

{{issue.Invoice Amount.asCurrency}}

It appears that all I would need to do is replace "Invoice Amount" with my custom field number field "Expense Total (?)" to make this happen. I have tried logging values in the automation to see what is happening but I get nothing back from that.

 

Rafael Ibanhez September 12, 2023

Hello. 

You can't use this function on numerical field. It needs to a text field.

Check automation log and you will see the following message if you use a numerical field: 

"Could not convert the field value to a number. Please ensure the value is a number, math expression or smart-value that can be converted into a number."

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.
September 12, 2023

Hi @Danno 

What do you observe happening when you try this: the value is unformatted, is empty, something else?

And, I noted that you typed this for the custom field name: "Expense Total (?)"  Thus the smart value would be: {{issue."Expense Total (?)"}}  First thing, is that a typo in the name?  Next...

Smart values are name, spacing, and case-sensitive, and do not always exactly match the field name shown on the page.  You can confirm the correct smart value with your field using this how-to article linked below. 

Essentially you find an example issue with your field, call a REST API function with a browser, and then search for your field on the page to determine the correct smart value (or the custom field id).

https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

Kind regards,
Bill

Rafael Ibanhez September 12, 2023

Here is an example of using smart values with automation. 

In this example, I'm taking the Description field, adding information from "Due Date" and "Subtotal1". 

Due date = date field

Subtotal = numerical field. 

smart_values.png

Description field value before running the rule:

Description_before.png

and this is after running the rule:

Description_after.png

 

Note that the currency function took place in the automation and changed the value of 1500 from my Subtotal1 custom field and parsed as a currency.

Does that makes sense?

Kayleen Cucugliello August 8, 2024

What is the Subtotal field? This is not working for me.

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 8, 2024

Hi @Kayleen Cucugliello 

For the post shown above referring to "Subtotal", that is a custom field in their Jira site / project.  If you do not have a field with that name, it would not be present.

If that does not help you, I recommend creating a new question and perhaps adding a link to this one for context.  That will ensure the maximum number of people see it to offer suggestions.  Thanks!

Kind regards,
Bill

Kayleen Cucugliello August 29, 2024

Thanks Bill! Will do! :)

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events