Forums

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

Display number in 1000 Multiples

Marzi Goodarzian
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 25, 2019

Hello

I create a script field in my Jira, and I want  number intered in this field displays in 1000 multiples.

for example:

When user in Create Screen entered number(456243) in "Number" field, Instantly value shows (456,243)  in this field(before create issue).

 

I  wrote a script in "script field" ,but it return  error.

Please Help me to write correct script.

Import com.atlassian.jira.component.ComponentAccessor

Define Number=ComponentAccesor.getCustomFieldManager().getCustomFieldObjectByName("Number");

Return issue.getCustomFieldValue(Number)/1000

 

Thanks

1 answer

0 votes
Leo
Community Champion
November 25, 2019

Hi @Marzi Goodarzian,

I would suggest you to go with Number field(custom field instead of script) and write a behaviour for the same(which will set/display value before clicks create button once focus changed to next field) 

below behaviour snippet may give you some reference

def cf = getFieldByName("Field Name")  // getting field
def cValue = cf.getFormValue() as Double //getting it's value from the form/screen
cValue = cValue/1000 // performing action
cf.setFormValue(cValue) // setting it's value in the current form/screen

BR,

Leo

Marzi Goodarzian
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 25, 2019

Hi @Leo 

I use your solution, but my problem don't resolve. :(

I define behaviour for this field and write your script but number in this field shows like before.

Example:

I enter 1234567

And show 1234567

While I want shows 1,234,567

Thanks

Leo
Community Champion
November 25, 2019

I misunderstood your query, I'm not good at formatting things. :(

Suggest an answer

Log in or Sign up to answer