- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 05:47 AM
Hi,
I have a decimal field Payback period but it does not show decimal value.
19350/252 = 77.4 but it shows only 77.
Client script for that is,
Thanks,
Vaishnavi
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 06:53 AM
script i have tested on my personal instance and worked.
function onSubmit() {
//Type appropriate comment here, and begin script below
var currency_amount = g_form.getIntValue('total_costs');
var currency_code = g_form.getIntValue('score');
g_form.setValue('u_mytest', currency_code/currency_amount);
}
u_mytest was initially as "integer" type . and i had more than 20 record which was holdig the value, i just deleted and changed the type and then applied onSubmit client script to set the value and its setting as decimal.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 07:00 AM
The below code is tested, it works:
var tpc = g_form.getValue('u_total_project_cost').split(';')[1].replace(/,/g, "");
var neb = g_form.getValue('financial_benefit').split(';')[1].replace(/,/g, "");
var total2 = parseFloat(tpc)/parseFloat(neb);
alert('tpc = '+tpc+' neb = '+neb+' total2 = '+total2);
g_form.setValue('u_payback_period',total2);
If it doesn't work, then can you at least paste what are you getting in alert.
I get this when I try this code:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2021 03:42 AM
Its not showing any value in the field. I am not sure why.
The code somehow does not work for me.
No Error but it did not show any value in the field in the form.
I am not an expert as well.
Thanks & Regards,
Vaishnavi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 05:52 AM
While adding the " 77.4" manually, is it considering as decimal ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 06:07 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 06:09 AM
i am saying,disable the script and manually add that 77.4 on that column and save it, see if its accepting or not. if its accepting check if you have script written correctly here.
add alert to troubleshoot it.