- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 02:21 AM
Hello... I'm a newbie on servicenow. I want to ask how to convert currency, glide date and decimal to float so i can get result from multile them.
Contract Value = Currency
Penalty percentage = Decimal
Over due date = glide date --> i get the value from today - end date (onChange=today)
I want to get value breach penalty from multiple 3 field. i use on change = over due date. i make this script. but it not working. please help. i can't do script well. thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-03-2017 09:16 PM
This should help.
var con = g_form.getValue('u_contract_value').substring(4);
var per = g_form.getValue('u_penalty_percentage');
var total = parseFloat(con) * parseFloat(per);
g_form.setValue('breach_penalty_amount', total);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 09:33 PM
Hello...
I still got NaN value when i try this script.
I cant get the right value when i try to convert it. when i convert decimal (0,1) using parseFloat, the result become 1. -,-"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 09:40 PM
there should be decimal not comma in u_penalty_percentage field.
can you please change this line
var value = g_form.getValue('u_contract_value');
to
var value = g_form.getValue('u_contract_value').replace(",", ".");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 12:52 AM
Hello...
I use comma because when i used (.), 0 disappear. 0.1 --> become 1. The value still NaN. I still cant get the right value...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 06:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 05:58 PM
Hello...
I'm using istanbul too.
But i create new personal istanbul instance to try the script. and the script still cant working properly. this is my script. i create client script onload to test it.
var con = g_form.getValue('u_contract_value');
alert(con); // this value is 1000
var per = g_form.getValue('u_penalty_percentage');
alert(per); // this value is 0.1
var total = parseFloat(con) * parseFloat(per);
alert(total); // this value is NaN
alert('TEST');
g_form.setValue('breach_penalty_amount', total);
Thank you