Forums

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

How to remove comma when getting value from a field with number type

Erdős Zoltán January 7, 2021

The thing is: I have 2 customfields, first is a number type field, second is URL type field.

 

When a user modifys the number type customfield, I want to copy that value into an another customfield(which is the URL type field).

The URL field has a Prefix, and the end will be the value of the number type customfield that the user just typed into the number type field.


I succesfully solved this problem wih Automation, but when I getting the value of the modified customfield(number typed), it will put comma inside the numbers. Like: 1 -> 1.0

How can I replace those commas?

In My Automation rule, my "additional fields" JSON is: 

{
 "fields": {
  "My URL Customfield": "https://someurl.com&id={{issue.customfield_10071}}"
 }
}

I tried to use smart values - JSON functions but, it won't worked for customfields somehow...

 

Thank you for your help,

Zoltan Erdos

2 answers

1 accepted

1 vote
Answer accepted
Daniel Ebers
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.
January 9, 2021

Hi @Erdős Zoltán

from the looks I solved the riddle - but please do an own test. Happy if you can confirm if it is what you were looking for.

I am just showing the difference to your JSON snippet, do let me know if you need further information:

{
"fields": {
"customfield_10082": "https://www.example.com&id={{customfield_10081.format("###")}}"
}
}

 

grafik.png

 

Cheers,
Daniel

Erdős Zoltán January 12, 2021

Hi Daniel,

 

Thank you so much, it is working! 


Cheers,

Zoltan

0 votes
Prince Nyeche
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.
January 8, 2021

Hi @Erdős Zoltán 

The number field is translating to float value. I don't think you can convert that easily. so it's better you simply use text custom field rather than number field type. If you still want to use the number field, then you should look at the functions for maths expression, like rounds().

Erdős Zoltán January 8, 2021

Thanks, I think maths expressions are not solve my problem here. (eliminate comma)

Okay, I can change it to Text Field, but I wanted that the user only can type numbers to this field, and with text field how it is possible? 

I need to implement some triggers to the workflows?

Prince Nyeche
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.
January 8, 2021

I know script runner can do such which is an additional addon and cost. however ensuring the text field is of type numbers with validators with Jira's native feature I don't think that exist except what you can do is create a third field of text field type, copy the value from the number field type into the text field and use the text field in the url field.

Like Erdős Zoltán likes this
Erdős Zoltán January 8, 2021

Hmm, I will try your alternative solution. Thanks.

Erdős Zoltán January 8, 2021

Unfortunately, it won't work, but it is logical.

I copied from number field into a text field, but the moment that I copied into a text field, it copied with comma into it, just like when i copied into URL field from number field.

 

image.png

Prince Nyeche
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.
January 8, 2021

Probably better to simply just use a text field. I checked on the Workflow feature for validators there's an option you can actually use as a validator with "Regular expression check" that should help validate for number input on the workflow for the custom field.

Like Erdős Zoltán likes this
Erdős Zoltán January 8, 2021

Yeah, that could work if I put it to every transition. But what will happen when the status of the issue doesn't change, just somebody modify that customfield? The validator will triggered when there is a transition, right?

Prince Nyeche
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.
January 8, 2021

Yes, the validator will only trigger when there is a transition. The best scenario here is to use an advance script such as script runner but again that's just additional cost. which i won't recommend for this type of use case.

Like Erdős Zoltán likes this

Suggest an answer

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

Atlassian Community Events