Hi,
Could someone help me please? I would like to change the separators of my script field (number)
12,345.67 --> 12 345,67
How could I do this please? I think I have to write something here (in the Custom Script Field editor), but I don't know what:
You'll need to do the formatting in your code, then just put $value into the template (or change the template to text)
Hi Nic,
Thank you for your answer. Yet I don't know how to format it in the script... (I don't code)
Could you please tell me what to add in ?
Regards,
Camille
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The format you've put in the question is not familiar to me, I'm used to seeing people ask for numbers to come out in their local language format (e.g. in English and US English, we have the format you are converting from, but in Spanish, you'd see 12.345,67)
If it is a valid format for a country (probably is), then
return NumberFormat(getNumberInstance(Locale.xx).format($number))
Would format it for the country named by the xx (US for USA, CH for Switzerland, GB for the UK, DE for Germany etc)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your help. I added this at the top of my code
import java.text.NumberFormat
And that at the end:
def frenchnumber = NumberFormat.getCurrencyInstance(Locale.FRENCH).format($number);
return frenchnumber;
Yet, for 12,345.67 : I get 12 (what I expected was 12 354,67)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hm. What is actually in $number ? Could you temporarily "return $number" at the bottom and hit preview to see it with the default java format?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
"return $number" gives me 12,345.67 but I found the issue: this was just due to my profile settings set to English by default. Changing the language and choosing "Number" in the template of the script field solved the problem.
I did not noticed that before, this is the 1st time I use Number fields with big values :)
Thank you for your help Nic!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ahh! Well spotted!
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.