Hi
I used number field and recieved phone number from customer,and was shown like 123,456,789 in view screen, then I created script field and convert this number to 123456789.
But When this number end to 0, number shown like 123456789E+9!!
My script is:
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser;
def customFieldsManager = ComponentAccessor.getCustomFieldManager();
CustomField phoneNumber = (CustomField)customFieldsManager.getCustomFieldObject(14101);
if (phoneNumber == null )
return "";
String phoneNumberVal = issue.getCustomFieldValue(phoneNumber)
return phoneNumberVal.toBigDecimal().abs()
-->14101:FieldID
How fixed it?
This E+ notation is the standard way to present numbers that are very large, and/or don't fit in fields. It's a bit like saying "a one followed by twelve zeroes" instead of "a trillion"
There's nothing you can do about this directly, it's the way numeric fields are intended to work.
But. A telephone number is not really a number, it is a strong (it's a series of instructions to "select each symbol in turn if you want to ring this person/place". Another way to look at it is "outside 'magic' tricks, would you ever find dividing it by 4 useful?", or consider that spaces, +, ( and ) are valid in telephone numbers too - they're not numeric)
So there's a simple answer - use a string (short text) field for it instead. These will not see the number as numeric and hence will not reformat it.
I used string field and for some number , the previous thing happens again(E+ notation).
How fix it completely?
Thanks alot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
String fields don't convert numbers to that format, they read everything as a string. Of course, if you copy and paste an E-formatted number in, it will retain the E as a string.
But just putting plain characters into a string field won't convert (put some spaces in if you're unsure - 0207 123 4567 for example, can't ever be interpreted as a number by a string field)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.