Number format conversion

sreeram_anikodemahadevan September 13, 2023

I am trying to auto populate a number field from a custom text field on transition using automation.

I have a custom text field that holds a hexadecimal value, which I would like to convert to decimal value and populate that in to a number field when transitioning the state from any-state to "done".

I am able to read the string from the custom-text field using automation but am unable to change the format to decimal

tried using field.asNumber.format option, but its not working (changes value to None)

Example value in text field - 0xA

Expected value in number field - 10

How can I achieve this during the automation?

1 answer

1 accepted

1 vote
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.
September 13, 2023

Hi @sreeram_anikodemahadevan -- Welcome to the Atlassian Community!

You may force the conversion by adding the hexadecimal value to 0 in a math expression, like this:

{{#=}}0+{{issue.MyHexField}}{{/}}

Kind regards,
Bill

sreeram_anikodemahadevan September 13, 2023

Thanks @Bill Sheboy worked like a charm

Like Bill Sheboy likes this
sreeram_anikodemahadevan April 18, 2024

@Bill Sheboy how do we do the other way around as well?
I doing a math on the HEX field and writing to another field. The resulting number always ends up in decimal. 
How do I convert the decimal to hex?

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.
April 18, 2024

I was not able to find support for that in automation rules, such as with the format() function.

sreeram_anikodemahadevan April 18, 2024

So that would be a no go then.

Any other thoughts on converting an integer to hexadecimal?

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.
April 18, 2024

Before doing this, my question would be: what problem is this solving?  

 

Some workarounds I can think of are:

  • Don't do it.  If the data is being passed to another system, it is likely systems / code outside of automation rules can do this more easily so let them handle the conversion.
  • If you know the maximum possible value, use progressive modulo division (or division plus the floor function) and a lookup table to convert the values manually, concatenating the digits.  The lookup table would have the values to convert from 0-F for each decimal digit value.
  • call an external REST API service with the Send Web Request action to perform the conversion
sreeram_anikodemahadevan April 18, 2024

I have a list of stories with requests for getting assigned with a sequentially progressing hexadecimal number.

When the issue get approved I would like the automation to look at the last assigned hex number increment it by '1' and update the issue which got approved. 

Suggest an answer

Log in or Sign up to answer