Setting currency value via client script

ilkka
Tera Expert

Hi,

I am trying to set currency value to 1 with g_form.setValue("field", "1");

When this client script runs it puts the value 1,00 to the field and after I save the record the value changes to 100.00

I have also tried with GlideAjax but same result. Any ideas?

 

Thanks

.: Ilkka 

1 ACCEPTED SOLUTION

ilkka
Tera Expert

I found the reason for this behaviour and tried it within my own dev instance. It is because this instance has glide.system.locale value of en.FI and it is actually not supported. the locale should be fi.FI 

here is the docs site about system locale

https://docs.servicenow.com/bundle/madrid-platform-administration/page/administer/currency/concept/l...

and here is the list of supported locale values

http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html

Kind of bad situation because the customer I am working on has the same value in production instance as well, and now I am not sure if it is wise to change it. The docs point out that it should not be changed after the instance is in production. 

 

.: Ilkka 

View solution in original post

12 REPLIES 12

The currency field only have 1 decimal deparator and thats . (dot)when you set the value in the field
So you just need to make sure that IF your getValue() or variable contains , (comma) as separator then you need to convert it to . (dot) before you set the value again.

Thats what my script does in that community post

ilkka
Tera Expert

I found the reason for this behaviour and tried it within my own dev instance. It is because this instance has glide.system.locale value of en.FI and it is actually not supported. the locale should be fi.FI 

here is the docs site about system locale

https://docs.servicenow.com/bundle/madrid-platform-administration/page/administer/currency/concept/l...

and here is the list of supported locale values

http://www.oracle.com/technetwork/java/javase/javase7locales-334809.html

Kind of bad situation because the customer I am working on has the same value in production instance as well, and now I am not sure if it is wise to change it. The docs point out that it should not be changed after the instance is in production. 

 

.: Ilkka 

saidinesh
Tera Expert

Currency field will store the data in following format

Currency;amount -> example:   USD;1  ->if you specify 1$

 

try alerting the value alert(g_form.getValue(currency_field)); and set the same value to currency field