How can I format a calculated total to have 1000 separators

Mike Low November 6, 2023

Hi,

I have 3 numeric custom fields. I have used each of the values from these fields to perform a calculation and render the value in a 4th read only text field (I'm unaware of a any numeric read only custom field so needs to be text). I have already created the necessary logic to using the following automation rule:

{{#=}}({{issue.fields.Custom Field 1}} * 100 + {{issue.fields.Custom Field 2}} * 110 + {{issue.fields.SCustom Field 3}} * 105) * 1.15 * 1.1{{/}}

I wish to format this value to have a 1000 separators as the value is currently hard to read e.g. instead of 1000000 it should render on screen as 1,000,000

 

I see that you can apply the format() option to a specific custom field (e.g. https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/) value but how can I apply it to a group of custom fields that are calculated into one value?

Thanks

Mike

1 answer

1 accepted

0 votes
Answer accepted
Marc - Devoteam
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.
November 7, 2023

Hi @Mike Low 

You could try the smart value asNumber.

This takes a string, and converts it to a number if possible.

{{issue.Custom Field 4.asNumber}}

Mike Low November 7, 2023

Thanks @Marc - Devoteam .

At what point in the rule would you place this?

In the rule I've created the Custom field 4 is not included in the calculation. It is merely selected as the field to be calculated. See below the highlighted drop down is the Custom Field 4 custom field 4.png

I tried adding a THEN component at the end of the rule = {{issue.Custom Field 4.asNumber}} but this just overrides the calculation that was made with NULL

Marc - Devoteam
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.
November 7, 2023

Hi @Mike Low 

This would require 2 extra actions in your rule I think.

  1. Add Re-Fetch Data action
  2. Edit action, to set the field using the smart value
Mike Low November 7, 2023

Thanks @Marc - Devoteam . I tried the below (adding those 2 components after the calculation components have run but unfortunately the calculated data is still getting cleared. image.png

I can confirm that if those 2 components are not in place the field calculates and renders successfully.

Marc - Devoteam
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.
November 7, 2023

Hi @Mike Low 

Could you set the customfieldId instead on the name?

example: {{issue.customfield_10101.asNumber}}

Find Custom Field ID

Mike Low November 7, 2023

Thanks @Marc - Devoteam .

I tried this and it unfortunately didn't work. Note I did realise that my custom field 4 is not purely numeric as I prefix it with a currency value of "R". I removed this from the calculation so that the field would be purely numeric but unfortunately the field is still being overwritten with NULL when those 2 components are added to the rule.

image.png

Marc - Devoteam
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.
November 7, 2023

Hi @Mike Low 

If you would place the re-fetch and edit action in the if and else statements.

I think now te re-fetch is done before the edit action in the if or else statement.

If this is not a working solution, you might need to reach out to Atlassian Support or I will try to mock this up on my instance, but I will need time to do so.

Mike Low November 7, 2023

Thanks @Marc - Devoteam .

I added the 2 components within the if statement as follows:image.png

The good news is that it does render the number and not NULL now. However, it renders the same as if the 2 components were not there as well so does not format the number to have 1,000 separator e.g. image.png

I don't want to take too much of your time so don't mind passing this query onto Atlassian if you prefer.

Marc - Devoteam
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.
November 8, 2023

HI @Mike Low 

I did a good re-read of the documentation on smart values and found a similar issue on the community.

Can you try the following, use the smart-value;

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

This might just work, if not, then it onlly applies to number fields.

Mike Low November 10, 2023

Bingo! This worked like a charm when running in the if statement, with the re-fetch component and the edit field component using that latest smart value you provided. Thank you @Marc - Devoteam !!!

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