Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Number to string automation

Petr AST
Contributor
May 17, 2024

Dear Community!

I'm trying to convert a number to a string, but my attempts have not yet been successful.

TN.png

There is an number field, but when you try to send an email or comment with this value, it is converted to a mathematical format  - 1.23123123123E11
Is it possible to somehow convert the field to a string?

I tried the following options, but none of them worked.

Number: {{issue.fields.customfield_10000.toNumber().toString()}}
Number2: {{issue.fields.customfield_10000}}
Number3 {{issue.fields.customfield_10000.toString()}}
Number4: {{issue.fields.customfield_10000.tostring}}
Number5: {{issue.fields.customfield_10000.asString}}
Number6: {{issue.fields.customfield_10000.asString()}}

 N.png

Thanks in advance!

4 answers

1 vote
Tugba Capaci
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.
May 17, 2024

Hi @Petr AST,

You can check out the smart values doc for custom fields here.

Try to use the name of your custom field instead of customfield_10000.

The format should be : {{issue.Custom field name}}

- To test your scenario, I created a number field:

Screenshot 2024-05-17 at 16.03.19.png

- And then, in the rule, I tried to add this field as a comment using the following rule:

rule.png

- As a result, it correctly added the number field to the issue's comment like:


Screenshot 2024-05-17 at 16.02.56.png

I hope this helps.

Tugba
actioner.com 

Petr AST
Contributor
May 22, 2024

Hi @Tugba Capaci 

Unfortunately it didn't help, the phone number is indicated without a dot and looks like a large number

1 vote
Vijay Dadi
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.
May 17, 2024

try - AsString(customfield).

hope it works

 

Petr AST
Contributor
May 22, 2024

Hi @Vijay Dadi 

Thanks for your answer

Unfortunately it didn't work, can't get value via AsString(customfield), tried various options((

0 votes
DD November 8, 2024

Thx to @Tugba Capaci 

on the trigger "field change" it was possible to convert the number field value to a String expression, using your provided Link:

{{fieldChange.toString}}

which i was then able to modify using common methods, in my case, extract the first digit:

{{fieldChange.toString.substring(0,1)}}

maybe this helps someone also ;-)

cheers, folks.

0 votes
DD November 7, 2024

Hi @Petr AST

wondering if you ever found a solution to your problem? 

I'm facing the same issue, trying to convert a number field into a string and use the string (to find the 1st and 2nd digit in the number).

I've also tried the options you mentioned above and do not get a string, but am able to retrieve the number from the customfield itself and also i'm able to get the digits, if using a text field.

Though, as you, i do need to do the convert from Number to String! 

I've (also) tried:

  • toString
  • toString()
  • tostring
  • tostring()
  • toNumber().toString()
  • asString
  • asString()
  • asstring
  • asstring()

What did you do in the end to solve your issue? Creating a Text Field works for me, but is not an option, because the Number Field is already in productive use...

Cheers, Dennis.

Suggest an answer

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

Atlassian Community Events