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

not sure why are you getting this output. i tried on my pdi and if i set value as 1 then it's setting as 1.00 which is correct. because currency will show it as decimal. 

 

adding one thread here . kindly have a look. 

 

Setting Currency Field values via client-side script

Sorry, solution behind the link didn't work

I think this has something to do with the en.FI localization. 

I just tried that I have this in the client script

g_form.setValue('field','0,01'); 

and after the client script has run the field has value 0,01 but after save it is 1.00 like it should be.

This is weird behaviour. 

.: Ilkka 

seriously strange. in my system it's worked. 

Simon Christens
Kilo Sage

Hi

If the field is a Currency field then see my response in this thread.
Maybe it can help you

https://community.servicenow.com/community?id=community_question&sys_id=aaf28c27db8073c0d82ffb243996...

 

Hi Simon,

 

Tried your solution but still no success. I think this has something to do with the en.FI localization. 

In Finland, we have, as decimal separator but in the US (,) is a thousand separator and (.) is a decimal separator. 

I tried to run the same thing using business rule and it works. So the problem only occurs on client side scripting

 

.: Ilkka