How to convert and multiply currency, glide date, and decimal?

zulhiyatiuwi
Tera Expert

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)

find_real_file.png

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.

find_real_file.png

1 ACCEPTED SOLUTION

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);


View solution in original post

13 REPLIES 13

zulhiyatiuwi
Tera Expert

explorenow hello... i'm sorry for distrubing you. can you help me with this client script?? thank you


Please try like:



var date = g_form.getValue('u_over_due_date');


alert(g_form.getValue('u_contract_value')); //Let me know what are you getting here if this code is not working


var value = g_form.getValue('u_contract_value').substring(4);


var person = g_form.getValue('u_penalty_percentage');


var total = parseFloat(date) * parseFloat(value) * parseFloat(person);


alert(total);


g_form.setValue('breach_penalty_amount', total); //Please check the if the field name is correct, if it's a custom field then it should start with u_


Hallo... thank you for response my questiion...


I have been try this script, and this is what i get form the script



var date = g_form.getValue('u_over_due_date');


alert(g_form.getValue('u_contract_value')); //This code is working, i get 1000 from this code


var value = g_form.getValue('u_contract_value').substring(4);


var person = g_form.getValue('u_penalty_percentage');


var total = parseFloat(date) * parseFloat(value) * parseFloat(person);


alert(total); //But in this code i get NaN


g_form.setValue('breach_penalty_amount', total); //This field is default by servicenow. i didnt create this field




Please check if this helps.



var date = g_form.getValue('u_over_due_date');


var value = g_form.getValue('u_contract_value');


var person = g_form.getValue('u_penalty_percentage');


var total = parseFloat(date) * parseFloat(value) * parseFloat(person);


alert(total); //What you get here?


g_form.setValue('breach_penalty_amount', total);